User criteria to check if user is Manager AND he belongs to specific Location
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-09-2022 03:47 AM
Hi all, I have a condition where if a user belongs to Location: Wroclaw and if he "Is Manager", then only the record producer is visible, I tried writing the script and added Wroclaw iin locations and checked "Match all". But it is not working. Any idea on how to do this?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-09-2022 04:38 AM
Will this work for "Is Manager"? as it is a check box. It still restricts user from viewing.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-09-2022 05:29 AM
answer = checkCondition();
function checkCondition(){
var gr = new GlideRecord("sys_user");
gr.addQuery('u_ismanager', true); // modified here, it worked
gr.addQuery();
gr.setLimit(1);
gr.query();
var rec = new GlideRecord('sys_user');
rec.get(user_id);
var locationName = rec.location.name;
if(gr.hasNext() && locationName.indexOf('Wroclaw') > -1)
return true;
else
return false;
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-10-2022 05:39 AM
Hi
update as this since you want to check if logged in user has u_manager checkbox true or not
answer = checkCondition();
function checkCondition(){
var gr = new GlideRecord("sys_user");
gr.addQuery("sys_id", user_id);
gr.addQuery('u_ismanager', true); // modified here, it worked
gr.query();
var rec = new GlideRecord('sys_user');
rec.get(user_id);
var locationName = rec.location.name;
if(gr.hasNext() && locationName.indexOf('Wroclaw') > -1)
return true;
else
return false;
}
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
‎09-09-2022 05:28 AM
answer = checkCondition(); function checkCondition(){ var gr = new GlideRecord("sys_user"); gr.addQuery('u_ismanager', true); //modified, this worked gr.addQuery(); gr.setLimit(1); gr.query(); var rec = new GlideRecord('sys_user'); rec.get(user_id); var locationName = rec.location.name; if(gr.hasNext() && locationName.indexOf('Wroclaw') > -1) return true; else return false; }
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-09-2022 05:38 AM
Hi,
Could you please check with below script:
answer = checkCondition();
function checkCondition(){
var gr = new GlideRecord("sys_user");
gr.addQuery("u_ismanager=true^locationLIKEWroclaw"); // modified here
gr.setLimit(1);
gr.query();
if(gr.hasNext())
return true;
else
return false;
}
Please mark my respsone as helpful/correct, if it answer your question.
Thanks