- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-17-2024 09:45 AM
Hello all,
I have a reference variable(select_the_group_to_add_remove_users) that is collecting all the groups that the requested_for is the manager. (working fine)
I have another variable list collect (please_select_the_user_to_be_added_to_the_group) collecting from sys_user.
This variable should only show members from the first variable (select_the_group_to_add_remove_users), group that the manager selected first.
I already tried some scripts, script included and nothing is working for me.
Can I have some help here?
Thank you in advance.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-17-2024 12:09 PM - edited 05-17-2024 12:45 PM
Hi @rafaelalves4337 ,
You can create a advance reference qualifier and call a script include in that you can return the group members as shown below, I have tried the below in my pdi its working,
Reference qualifier,
javascript: new getManagerGroup().getUser(current.variables.select_the_group_to_add_remove_users);
Script inlcude:
var getManagerGroup = Class.create();
getManagerGroup.prototype = {
initialize: function() {
},
getUser: function(groupID){
var gr = new GlideRecord('sys_user_grmember');
gr.addQuery('group',groupID);
var arr =[];
gr.query();
while(gr.next()){
arr.push(gr.getValue('user'));
}
return 'sys_idIN' + arr;
},
type: 'getManagerGroup'
};
Please mark this comment as Correct Answer/Helpful if it helped you.
Regards,
Swathi Sarang
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-17-2024 10:10 AM - edited 05-17-2024 10:11 AM
add this in advanced reference qualifier of second variable . update that first_variable in script with your variable name
javascript:'sys_idIN'+getIDs(current.variables.first_variable); function getIDs(grp){var m=GlideUserGroup.getMembers(grp);var ids=''; while (m.next()){ids+= (m.user+',');} return ids;}
Please mark my answer correct and helpful if this works for you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-17-2024 12:03 PM
It did not work, it's bringing all the users in the sys_user table.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-17-2024 10:44 AM
Try below:
Script Include:
var groupUtils = Class.create();
groupUtils.prototype = {
initialize: function() {
},
getGroupMembers: function(group) {
var groupMember = new GlideRecord("sys_user_grmember");
groupMember.addQuery("group", group);
groupMember.query();
var ids = "";
while (groupMember.next()) {
if (ids != "")
ids += ",";
ids += groupMember.user.toString();
}
return "sys_idIN" + ids;
},
type: 'groupUtils'
};
Next, update the reference qualifier on second variables like below:
javascript: new groupUtils().getGroupMembers(current.variables.select_the_group_to_add_remove_users);
Please mark my answer correct and helpful if this works for you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-17-2024 12:02 PM
It did not work too, it's bringing all the users in the sys_user table.