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 to get users who is having itil role using backgeound script

Vyanktesh08
Tera Contributor

I want to fetch names of users using background script who is having itil roles.

1 ACCEPTED SOLUTION

Anurag Tripathi
Mega Patron
Mega Patron

Hi,

Try this.

 

var records = new GlideRecord('sys_user_has_role');
records.addQuery('role', '<sys id of ITIL Role>');
records.addQuery('state', 'active');
records.query();
while (records.next()) {
	gs.print(records.user.name);
}
-Anurag

View solution in original post

3 REPLIES 3

Anurag Tripathi
Mega Patron
Mega Patron

Hi,

Try this.

 

var records = new GlideRecord('sys_user_has_role');
records.addQuery('role', '<sys id of ITIL Role>');
records.addQuery('state', 'active');
records.query();
while (records.next()) {
	gs.print(records.user.name);
}
-Anurag

Thanks @Anurag Tripathi 

Cheers mate!!

-Anurag