- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-08-2022 06:42 AM
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
Solved! Go to Solution.
- Labels:
-
HR Service Delivery
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-08-2022 06:45 AM
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
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-21-2023 04:41 AM
Can you post a new question and tag me there as this is an older thread?
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-08-2022 06:46 AM
hello
i think you can try this so if that person has reportees he must be a manger for those reportees so you can try this
answer=false;
isManager();
function isManager()
{
var gr = new GlideRecord('sys_user');
gr.addQuery('manager',gs.getUserID());
gr.addQuery('active',true);
gr.addQuery('location','your_cmn_location_record_sys_id');
gr.query();
if(gr.next())
{
answer=true;
}
else
{
answer=false;
}
}
Hope this helps
Mark the answer correct if this helps you