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.

how we can print the users who are part of application development group using business rule

Sandeep74
Tera Expert

need the code to display the users 

1 ACCEPTED SOLUTION

Sourabh26
Giga Guru

Hi,

Try below code in background script.

var grGroup = new GlideRecord(sys_user_grmember);
grGroup.addQuery('group','GROUP_NAME');
grGroup.query();
while(grGroup.next()){
  gs.info(grGroup.getDisplayValue('user'));
}

If you want to run in BR then configure BR on sys_user_grmember table and use above code (do not glide then use the current object)

 

Mark this as Helpful/Correct, if Applicable.

 

Regards,

Sourabh

View solution in original post

3 REPLIES 3

Sai Kumar B
Mega Sage

Hi

Try the below code in the background script

var arr=[];
var getMembers = new GlideRecord('sys_user_grmember'); //Group membership table
getMembers.addQuery('group', 'group_sys_id'); //Query with Application Development group sys_id
getMembers.query();
while(getMembers.next()){ //Iterate over records
arr.push(getMembers.getDisplayValue('user'));  //Push Display value of users into array
}
gs.print(arr); //Print array

Sourabh26
Giga Guru

Hi,

Try below code in background script.

var grGroup = new GlideRecord(sys_user_grmember);
grGroup.addQuery('group','GROUP_NAME');
grGroup.query();
while(grGroup.next()){
  gs.info(grGroup.getDisplayValue('user'));
}

If you want to run in BR then configure BR on sys_user_grmember table and use above code (do not glide then use the current object)

 

Mark this as Helpful/Correct, if Applicable.

 

Regards,

Sourabh

Gunjan Kiratkar
Kilo Patron
Kilo Patron

Hi @Sandeep,

I have a couple of questions

1) Where do you want to display that user's name using the Business rule. Is it in a specific field or just an info message?

2) When do you want to display that user's list? On create or on an update?

 

Regards,

Gunjan Kiratkar

Consultant - ServiceNow, Cloudaction

Rising Star 2022


Please Mark My Response as Correct/Helpful based on Impact
Regards,
Gunjan Kiratkar
2X ServiceNow MVP
Community Rising Star 2022
Youtube : ServiceNow Guy