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

still same not sure where its having issues tried different scenarios 

Naneen_0-1697569203814.png

 

i have also tried like this to get the groups (its working) but its giving the Parent of the group also.

FYI may be we can modify that?

 

javascript:'typeLIKE sys_ID of type^sys_idIN' + new global.ArrayUtil().convertArray(gs.getUser().getMyGroups());

Uday Soni05
Tera Guru

Hi @Ram050670 ,

Update the Code for Reference Qualifier as below :

javascript: new CatalogClientUtil().getUserRequestGroups(gs.getUserID());

And Script Include like this:

 

getUserRequestGroups: function(userId) {
var groups = [];

var gr = new GlideRecord('sys_user_grmember');

gr.addQuery('user', userId);

gr.addQuery('group.type', 'sys_id of your group type request');

gr.query();

while (gr.next()) {

groups.push(gr.group.toString());

}

return 'sys_idIN' + groups;

},
 
It should work
 
Please mark this comment as Correct Answer/Helpful if it helped you.
Regards,
Uday
 

Just try this once and let me know

 

Naneen_0-1697570534303.pngNaneen_1-1697570552477.pngNaneen_2-1697570596478.png