How to create User criteria with the script to check whether the logged-in user has any direct reportee who are active and from XYZ location can access the HR catalog

Deactivate User
Tera Contributor

How to create User criteria with the script to check whether the logged-in user has any direct reportee who are active and from XYZ location can access the HR catalog

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

use this user criteria advanced script

answer = checkCondition();

function checkCondition(){
	var gr = new GlideRecord("sys_user");
	gr.addActiveQuery();
	gr.addQuery("manager", user_id);
	gr.addQuery("location.name", "XYZ"); // give location name here
	gr.query();
	return gr.hasNext();
}

Regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

View solution in original post

6 REPLIES 6

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

use this user criteria advanced script

answer = checkCondition();

function checkCondition(){
	var gr = new GlideRecord("sys_user");
	gr.addActiveQuery();
	gr.addQuery("manager", user_id);
	gr.addQuery("location.name", "XYZ"); // give location name here
	gr.query();
	return gr.hasNext();
}

Regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

I wants to know the manager's all direct reportees having XYZ location then it should be visible for manager else not 

Hi,

I assume even if 1 active reportee has that location then it should allow access

if yes then script I shared is fine

Regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

@Ankur Bawiskar @Mohith Devatte Can you please help me with country.

Based on country, Users should restricts for Knowledge Article.