Macro Engine - Fetching usergroups

    Macro Engine - Fetching usergroups

    Hi guys,

    I'm writing here to try to get a little support.

    While developping, I have to get the groups of the current user using the ME of JEDOX WEB.

    I have to simulate the "ctrl + shift + enter" in A1:A39 (for exemple) on the formula "=USERGROUPS()". When testing on JEDOX WEB it works (as it should), but I have to admit I'm not able to implement it on ME.

    For now I have tryed :

    Source Code

    1. activesheet()->range('A1:A39')->value='=USERGROUPS()';
    2. activesheet()->range('A1:A39')->value='{=USERGROUPS()}';
    3. activesheet()->range('A1:A39')->formula='=USERGROUPS()';
    4. activesheet()->range('A1:A39')->formula='{=USERGROUPS()}';
    5. activesheet()->range('A1:A39')->formulaArray='=USERGROUPS()';
    6. activesheet()->range('A1:A39')->formulaArray='{=USERGROUPS()}';


    Nothing works. (I guess it's normal for the last 2 since no formulaArray seems to be implemented according to the doc ?!)

    Well, thanks for help

    Ps : is it possible to fetch simply the results of the usergroups() in a $var or do we have to write it in cells then get it back (looping...)
    Hello trall,

    tested with the latest version:

    PHP Source Code

    1. $var=current_groups();


    still I don't know the format of the returned array. I tried this:

    PHP Source Code

    1. function getusergroups()
    2. {
    3. $var=current_groups();
    4. $imp=implode(';',$var);
    5. activesheet()->range('C8')->value=$imp;
    6. }


    If I allocate a user to many groups, the latter gives only the first group.

    that's strange cause when I write:

    PHP Source Code

    1. function getusergroups()
    2. {
    3. $var=current_groups();
    4. activesheet()->range('C8')->value=$var[0];
    5. }


    it returns the first one. But when writing:

    PHP Source Code

    1. function getusergroups()
    2. {
    3. $var=current_groups();
    4. activesheet()->range('C8')->value=$var[1];
    5. }


    It does not return anything.

    Hope this help though. If you cannot make it work then you can use the palo_getdata_export function and loop on it (this requires a user that has rights on the System database though)

    Cheers
    laloune
    laloune

    Post hoc, non est propter hoc

    Nice solution but ?

    Hi,

    First of all, thanks for fast answer !

    After tweeking a lil' it's work on my macro. But I got a question : how the f**k did you know there is a current_groups() function ?! I went through the doc' and didn't find something like that (only the USERGROUP() in a cell and the current_user() function in "top level function" of the jedox WEB doc').

    May be (I guess) I have missed an important doc'. If so, feel free to link it !
    Hi,

    can you post your code (or at least the current groups related part) ? did you get to display the 2nd group ?

    actually this function does not seem to be documented anywhere. i looked in the macro engine documentation and saw the current_user() function. I deducted that the current_groups() function could work

    cheers
    laloune

    Post hoc, non est propter hoc
    That's what I thought, this function isn't documented... But thanks for this tips !

    Well you can simply try

    PHP Source Code

    1. $grps=current_groups();
    2. activesheet()->range("A1:A3")->value=$grps;


    It'll display the groups in A1 -> A3. If you just go for return $grps you'll have an exploitable array (i'm doing some parsing on it for example)
    Current information about macro engine as well other topics can be found in our knowledgebase - knowledgebase.jedox.com/. Especially interesting for this thread:

    knowledgebase.jedox.com/knowle…s-exposed-to-macro-engine

    and the ZIP attached to that article with current documentation with samples.
    Mit freundlichen Gruessen/ With kind Regards / Meilleures salutations

    Vladislav Malicevic
    VP Development & Support
    Jedox AG