- 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-28-2025 04:16 AM
you can use advanced reference qualifier on that list field.
I assume list field refers to sys_user_group table
Something like this, ensure you give correct user field here
javascript: 'sys_idIN' + new global.ArrayUtil().convertArray(gs.getUser().getUserByID(current.userField).getMyGroups());
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-28-2025 05:48 AM
Hi Ankur Bawiskar,
thank you for the response,
but i need script because i need to filter to display only groups with "pps_resource" role and if current user is removed from any group or added should reflect on groups list as well
- 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:48 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