Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

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

In this video i have explained about Web service integration in ServiceNow like how it works, how we can configure it, what are the prerequisite and many more. I have covered below topics in this video. 1. understand Web Service. Like when and how we will use it. 2. Talked about Inbound and ...
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

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

 

 

 

 

 

In this video i have explained about Web service integration in ServiceNow like how it works, how we can configure it, what are the prerequisite and many more. I have covered below topics in this video. 1. understand Web Service. Like when and how we will use it. 2. Talked about Inbound and ...

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.