- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-28-2025 04:06 AM
Hello,
I have a requirement , when a user is selected from user field, the user added to particular groups list need to populated in group list field, so that more than one group can be selected.
if anyone can help me on this would be helpfull.
thank you
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-28-2025 06:12 AM
you can use script in the advanced ref qualifier as this so that it shows only the groups for that user which are having pps_resource role
Something like this
javascript: var query = '';
var userGroups = [];
var groups = new global.ArrayUtil().convertArray(gs.getUser().getUserByID(current.userField).getMyGroups());
// Query to check if the group has the pps_resource role
var grGroupRole = new GlideRecord('sys_group_has_role');
grGroupRole.addQuery('group', 'IN', groups.toString());
grGroupRole.addQuery('role.name', 'pps_resource');
grGroupRole.query();
while (grGroupRole.next()) {
userGroups.push(grGroupMember.group.toString());
}
query = 'sys_idIN' + userGroups.toString();
query;
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-29-2025 01:51 AM
Thank you for the response