- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
Hi All,
I have a requirement in a catalog item where:
- Variable A is a dropdown list of active users.
- Variable “please_select” allows selecting an action (e.g., Delete).
- When “please_select” = Delete and a user is selected in Variable A,
then Variable B (a reference field to sys_user_group) should display only those groups: - where the selected user is a member, and
- the group has the ITIL role assigned.
Can someone suggest the best way to achieve this setup via Dynamic Reference Qualifier or Script Include?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday - last edited yesterday
So user variable is reference and you want to show the groups to which that user belongs + group should have ITIL role?
if yes then do this in advanced reference qualifier in 2nd variable
Note:
1) give correct variable name for user
2) community converts colon : to : so when you copy take care of that
javascript: 'sys_idIN' + new global.ArrayUtil().convertArray(gs.getUser().getUserByID(current.variables.userVariableName).getMyGroups()) + '^roles=itil';
💡 If my response helped, please mark it as correct ✅ and close the thread 🔒— this helps future readers find the solution faster! 🙏
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday - last edited yesterday
So user variable is reference and you want to show the groups to which that user belongs + group should have ITIL role?
if yes then do this in advanced reference qualifier in 2nd variable
Note:
1) give correct variable name for user
2) community converts colon : to : so when you copy take care of that
javascript: 'sys_idIN' + new global.ArrayUtil().convertArray(gs.getUser().getUserByID(current.variables.userVariableName).getMyGroups()) + '^roles=itil';
💡 If my response helped, please mark it as correct ✅ and close the thread 🔒— this helps future readers find the solution faster! 🙏
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
Hi @Ankur Bawiskar ,
Thank you for your message. the solution which you provided is partially working that it's even showing the parent group that has itil role as well in the drop down.
How not to show the parent group? The user is not part of parent group.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
getMyGroups() bring parent group as well although user is not member of parent group
To overcome you can use scripting approach like this in advanced ref qualifier
javascript: var query = '';
var arr = [];
var gr = new GlideRecord("sys_user_grmember");
gr.addQuery("user", current.variables.userVariableName);
gr.query();
while (gr.next()) {
arr.push(gr.group.toString());
}
query = 'sys_idIN' + arr.toString() + '^roles=itil';
query;
💡 If my response helped, please mark it as correct ✅ and close the thread 🔒— this helps future readers find the solution faster! 🙏
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
Thank you @Ankur Bawiskar
I wrote a script include to filter the sys_id and called the script include from the reference qualifier.
javascript: 'sys_idIN' + new global.UserUtils().getUserITILGroups(current.variables.please_select_the_user_for_the_servicenow_account)