- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-10-2021 02:17 AM
Hi All!
I'm currently building a catalog item for a request to remove user from groups. There is firstly a user field from sys_user table and then groups field. What I'm trying to do is to link these 2 fields so when the user is selected, in the groups field would appear only the groups that this particular user is part of. Yet no success. Any ideas?
Thank you in advance.
Best regards,
Oleg.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-10-2021 02:28 AM
Hi,
You will have to create reference qualifier for the 2nd variable and call script include function
how to call script include in 2nd variable
javascript: 'sys_idIN' + new GetGroupMembers().getGroups(current.variables.userVariableName);
Script Include:
var GetGroupMembers = Class.create();
GetGroupMembers.prototype = {
initialize: function() {
},
getGroups:function(user) {
var group_array = [];
var getMembers = new GlideRecord('sys_user_grmember');
getMembers.addQuery('user ',user);
getMembers.query();
while(getMembers.next())
{
var groupSysId = getMembers.getValue('group');
group_array.push(groupSysId);
}
return group_array;
},
type: 'GetGroupMembers'
};
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-15-2021 10:09 PM
what is not working?
did you add gs.info() to debug
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-21-2023 05:23 AM
This might be Old post but just adding other option, so that some one can use it ,
In the Reference variable , Select group member table and use the group sysID , this will fix the issue
