Need help with population of roles and groups in catalog item
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 hours ago
Hi,
I’m working on a catalog item where I need to configure two fields with the below behavior:
Field Name: Roles assigned to the user
Requirement: It should show the list of all roles assigned to the logged-in user(Requested for) field, basically fetched from the sys_user_has_role table.
Field Name: Groups associated with the selected role
Type: Multi-select dropdown
Requirement:
When a role is selected in the “Roles assigned to user” field,
the system should display all groups associated with that role (in which the user is a member).
All those groups should be auto-selected by default, but the user should be able to deselect if needed.
I’m trying to implement this logic using a catalog client script and script include, but I’m not sure about the best approach to dynamically populate the multi-select dropdown based on the selected role.
Has anyone implemented something similar or can guide on the right way to achieve this (preferably without using gel or DOM methods)?
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 hours ago
Ideally you should do this
1) 1st variable point to sys_user_role table with advanced ref qualifier as this
javascript: var query;
var cu = gs.getUser();
query = 'nameIN' + new global.ArrayUtil().convertArray(cu.getRoles());
query;
2) 2nd variable point to sys_user_group, list collector type
refer my blog on how to set list collector based onchange + GlideAjax
Dynamically set list collector on change of variable
💡 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
