- 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 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 12:35 PM
Still not working....
I don't know what I'm doing wrong...
This is the result, all the users showing in the list, and in this particular group there are only 2 people.
Script Include is like this
This is the variable to select the users:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-17-2024 12:43 PM
@rafaelalves4337 reference qualifier written is wrong please correct it according to below image,
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-20-2024 05:39 AM