Catalog item form - variable to display only users/member of selected group
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-11-2025 07:58 AM
Hi,
I have create a Service catalog item and on the form I have two variables:
- Select group - The requester selects a group (the variable is type Reference to the sys_user_group table)
- Select members of the group - Then the requester should only be able to see and select one or more members of the selected group.
I am not able to achieve what I want with variable 2 i.e. only display the group members - so how should I do this?
Thanks 🙂
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-11-2025 08:05 AM
in the 2nd variable make it reference to sys_user
Use advanced reference qualifier as this
javascript: var query;
var arr = [];
var gr = new GlideRecord("sys_user_grmember");
gr.addQuery("group", current.variables.groupVariableName);
gr.query();
while (gr.next()) {
arr.push(gr.getValue('user'));
}
query = 'sys_idIN' + arr.toString();
query;
If you are making 2nd variable as list collector to sys_user then use same advanced ref qualifier, but give this in variable attributes
ref_qual_elements=groupVariableName
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-13-2025 08:05 AM
Hope you are doing good.
Did my reply answer your question?
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-04-2025 04:57 PM
I'm still learning about using Javascript, so i would like to check some things & hopefully get a better understanding of the script you have shared here.
When you use "groupVariableName", you are referring to the name you have given to the variable that you are using to determine the group that you are looking for the members of? eg: groupVariableName = the assignment group selected in the Catalog item form, which is the group selected first?
I have tried using this script replacing the groupVariableName with the name I assigned to the variable i have used to collect the Assignment group name. When i then attempt to test the catalog item, instead of only showing the members of the selected assignment group it shows all sys_users still, and I get multiple columns rather than just the name of the user.
Cheers