Built something you're proud of? Tell the story. A quick G2 review of App Engine or Build Agent helps other developers see what's possible on ServiceNow. Share your experience.

How to get users who is having itil role using backgeound script

VyankteshK
Tera Contributor

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

1 ACCEPTED SOLUTION

Anurag Tripathi
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

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