Interested in a ServiceNow event built for developers? Registration for now[dev]26 is officially open!

How to provide Group Members in Record Producer Reference field of User for particular group ?

VIKASM535239375
Kilo Sage

How to provide Group Members in Record Producer Reference field calling User form for particular group in Scoped Application

2 REPLIES 2

keshav77
Tera Expert

@VIKASM535239375  I would recommend using a Script Include for the reference qualifier instead of writing the complete logic directly in the Record Producer.

Create a Script Include to get the users from sys_user_grmember, and then call that Script Include from the Advanced Reference Qualifier of the User reference field.

Reference Qualifier:

javascript:new GroupMembers().getMembers('GROUP_SYS_ID')

This will keep the Record Producer configuration simple and make the logic reusable.

yashkamde
Giga Sage

Hello @VIKASM535239375 ,

 

You can add advanced reference qualifier in your variable section :

Screenshot 2026-09-09 141112.png

 

Then from script include filter out the users for particular group :

var GroupMemberUtils = Class.create();
GroupMemberUtils.prototype = {
    initialize: function() {},

    getGroupMember : function() {
        var groupSysId = '<your_group_sys_id>'; // or fetch dynamically
        var userIds = [];

        var gr = new GlideRecord('sys_user_grmember');
        gr.addQuery('group', groupSysId);
        gr.query();
        while (gr.next()) {
            userIds.push(gr.getValue('user'));
        }

        return 'sys_idIN' + userIds.join(',');
    },

    type: 'GroupMemberUtils'
};

 

If have to pass group dynamically :

javascript&colon;new GroupMemberUtils().getGroupMember(current.variables.group_field);

 

If my response helped mark as helpful and accept the solution.