I want to filter the input form to show only users belonging to a group.

bonsai
Mega Sage

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?

 

 

group_user.png

3 REPLIES 3

Dr Atul G- LNG
Tera Patron

Try these

 

https://www.servicenow.com/community/itsm-forum/how-to-show-only-users-from-respective-group-in-refe...

 

*************************************************************************************************************
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]

****************************************************************************************************************

Tanushree Maiti
Tera Sage

 

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.

Screenshot 2026-03-25 153611.jpg

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'};

 

Please mark this response as Helpful & Accept it as solution if it assisted you with your question.
Regards
Tanushree Maiti
ServiceNow Technical Architect
Linkedin:

its_SumitNow
Mega Sage

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