I want to filter the input form to show only users belonging to a group.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 hours ago
In the input form below, the "Group" field references "sys_user_group".
The "User" field references "sys_user".
I want to display only users belonging to the group record selected in the "Group" field as candidates for the "User" field.
Is this possible with no-code/low-code?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
an hour ago
Try these
Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/dratulgrover [ Connect for 1-1 Session]
****************************************************************************************************************
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
an hour ago - last edited an hour ago
Hi @bonsai
If user variable name is select_user and group variable is select_group then
- Set the Use Reference Qualifier to Advanced.( On user Variable)
- Call a Script Include and pass the value of the select_group variable. The syntax generally looks like this: javascript:new GroupUtils().getGroupMembers(current.variables.select_group).
- Note: You must check the "Global" flag on the script include if it's called from a catalog item.
Script Include:
var GroupUtils = Class.create();
GroupUtils.prototype = {
initialize: function() {},
getGroupMembers: function(groupID) {
var userSysIds = [];
var grMember = new GlideRecord('sys_user_grmember');
grMember.addQuery('group', groupID);
grMember.query();
while (grMember.next()) {
userSysIds.push(grMember.getValue('user'));
}
return 'sys_idIN' + userSysIds.join(',');
},
type: 'GroupUtils'};
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
an hour ago
Hi @bonsai
it's simple, But You need to write a script include and Reference qualifer on User Field (OOTB, there's no configuration to achieve this)
1. Script Include
var UserGroup = Class.create();
UserGroup.prototype = {
initialize: function() {},
getMember: function(group) {
var glideMember = new GlideRecord('sys_user_grmember');
glideMember.addQuery('group', group);
glideMember.query();
var members = [];
while (glideMember.next()) {
members.push(glideMember.getValue('user'));
}
return 'sys_idIN' + members.toString();
},
type: 'UserGroup'
};
2. Reference Qualifer
javascript: new UserGroup().getMember(current.your_group_field);This will work
Hope my solution helps,if yes then please mark helpful & Accept it as Solution 🙂
Regards
Sumit
