We're reclaiming inactive PDIs to keep them available for active builders. Learn what's changing, who's affected, and how to protect your work. Read More

Get User groups list from Requested For

Ram050670
Tera Guru

Hi All,

i would like to get List of groups (type = request) of user from requested for to a reference type field.

can someone help me with Script include and advanced reference qualifier.

 

Naneen_0-1697561192573.png

 

Thanks in advance!

 

1 ACCEPTED SOLUTION

Ram050670
Tera Guru

I would say this is the right way to do it on this request!!


--------------Script Include------------------------

 

getUserRequestGroups: function(userId) {
        var Gtype = gs.getProperty("Assignment_Group_Type");
        var gFilter = gs.getProperty("Assignment_Group_Dynamic_user");
        var groups = [];
        var gr = new GlideRecord('sys_user_grmember');
        gr.addEncodedQuery('group.typeLIKE' + Gtype + '^userDYNAMIC' + gFilter);
        gr.query();
        while (gr.next()) {
            groups.push(gr.group.sys_id.toString());
        }
        return 'sys_idIN' + groups;
    },
 
-----------------------Reference Qualifier-------------------------
 
javascript: new catalogClientUtil().getUserRequestGroups();
 
Naneen_0-1697729170438.png

 

View solution in original post

40 REPLIES 40

Not applicable

Hello @Ram050670 ,

Your script include code is not correct. You are not returning correct query.

Please refer to the below code:-

 

 

 

 

  getUserRequestGroups: function(userId) {
        var groups = [];
        var gr = new GlideRecord('sys_user_grmember');
        gr.addQuery('user', userId);
        gr.addQuery('group.type', 'request');
        gr.query();
        while (gr.next()) {
            groups.push(gr.group.toString());
        }
        return 'sys_idIN'+groups;
    },

 

 

 

 

Also, for Reference Qualifier your script is incorrect , refer to the below script:

 

 

 

Alka4_0-1697566146999.png

 

 

If this response clears up your doubt, kindly flag it as both helpful and correct.

Thanks,

Alka

@Community Alums tried you script and qualifier but still its showing all groups 

i am not sure whats wrong in it, tried different ways!

Not applicable

@Ram050670 Please replace you script include with my script and also reference qualifier then it will work. 

Harsh_Deep
Giga Sage

@Ram050670 

 

Can you please send your all screen shots again.

Naneen_0-1697566905454.pngNaneen_1-1697566938382.pngNaneen_2-1697566974009.png