Populate the reference variables on the catalog item level.

LaraReddy
Tera Guru

Hi All,

We do have a catalog item with two Reference type variables.

Now if on the first variable if we select any group then on the second variable level we need list out above selected group users.

Advance thanks.

Note: We tried the auto populate related section on the second variable level but it's not working.

Version = Washington DC.

1 ACCEPTED SOLUTION

Runjay Patel
Giga Sage

Hi @LaraReddy ,

 

You can configure like below.

RunjayPatel_0-1731074227207.png

 

Script include code:

var userUtils = Class.create();
userUtils.prototype = Object.extendsObject(AbstractAjaxProcessor, {

    getGroupMembers: function(group) {
		gs.log('Runjay'+group);
		var sysId=[];
        var gr = new GlideRecord('sys_user_grmember');
        gr.addQuery('group', group);
        gr.query();
        while (gr.next()) {
            sysId.push(gr.user.sys_id);
        }
        return 'sys_idIN'+sysId;
    },
    type: 'userUtils'
});

RunjayPatel_2-1731074352772.png

 

Output.

RunjayPatel_1-1731074281258.png

 

-------------------------------------------------------------------------

If you found my response helpful, please consider selecting "Accept as Solution" and marking it as "Helpful." This not only supports me but also benefits the community.


Regards
Runjay Patel - ServiceNow Solution Architect
YouTube: https://www.youtube.com/@RunjayP
LinkedIn: https://www.linkedin.com/in/runjay

-------------------------------------------------------------------------

 

 

 

 

 

View solution in original post

6 REPLIES 6

Runjay Patel
Giga Sage

Hi @LaraReddy ,

 

You can configure like below.

RunjayPatel_0-1731074227207.png

 

Script include code:

var userUtils = Class.create();
userUtils.prototype = Object.extendsObject(AbstractAjaxProcessor, {

    getGroupMembers: function(group) {
		gs.log('Runjay'+group);
		var sysId=[];
        var gr = new GlideRecord('sys_user_grmember');
        gr.addQuery('group', group);
        gr.query();
        while (gr.next()) {
            sysId.push(gr.user.sys_id);
        }
        return 'sys_idIN'+sysId;
    },
    type: 'userUtils'
});

RunjayPatel_2-1731074352772.png

 

Output.

RunjayPatel_1-1731074281258.png

 

-------------------------------------------------------------------------

If you found my response helpful, please consider selecting "Accept as Solution" and marking it as "Helpful." This not only supports me but also benefits the community.


Regards
Runjay Patel - ServiceNow Solution Architect
YouTube: https://www.youtube.com/@RunjayP
LinkedIn: https://www.linkedin.com/in/runjay

-------------------------------------------------------------------------

 

 

 

 

 

Hi @LaraReddy ,

 

Hope provided solution worked for you if yes then please accept the solution if not then let me know what issue still you are facing.

Happy to help you.