- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-25-2018 10:21 AM
Hi friends,
I'm building a User Criteria and need to have the script check the value of field on the logged in user's record in sys_user.
Trying a couple ways to do this and not finding the correct script. Anyone see why this isn't working? the top part that is querying to get the gr.u_region is working fine. It's the getDomain part that does not seem to be working. The field on the sys_user table I'm looking to see if it "== 'CTS'" is [u_ad_domain].
Thanks!
answer();
function answer(){
var loc = gs.getUser().getRecord().getValue('location');
var gr = new GlideRecord('cmn_location');
gr.get(loc);
var getDomain = new GlideRecord('sys_user');
getDomain.addQuery('sys_id',gs.getUserID());
getDomain.query();
if(gr.u_region == 'EMEA' && getDomain.u_ad_domain == 'CTS'){
return true;
}
}
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-25-2018 10:54 AM
Actually this is perfect
answer();
function answer(){
var getDomain = new GlideRecord('sys_user');
getDomain.addQuery('sys_id',gs.getUserID());
getDomain.query();
if (getDomain.next())
{
if(getDomain.location.u_region == 'EMEA' && getDomain.u_ad_domain == 'CTS'){
return true;
}
}
}
Thanks,
Sanjiv
Please mark this response as correct or helpful if it assisted you with your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-25-2018 10:31 AM
can u pls explain the exact requirement of this user criteria.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-25-2018 10:35 AM
Hi Anil,
thanks for the reply. I'm looking to use this User Criteria to restrict the accessibility of a catalog item to users in our company who have a specific region and AD Domain as specified on their user record.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-25-2018 10:50 AM
You dont need the scripts lines which are strike out.
answer();
function answer(){
var loc = gs.getUser().getRecord().getValue('location');
var gr = new GlideRecord('cmn_location');
gr.get(loc);
var getDomain = new GlideRecord('sys_user');
getDomain.addQuery('sys_id',gs.getUserID());
getDomain.query();
if(gr.u_region == 'EMEA' && getDomain.u_ad_domain == 'CTS'){
return true;
}
}
Please mark this response as correct or helpful if it assisted you with your question.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-25-2018 10:53 AM
Added one correction to script
answer();
function answer(){
var getDomain = new GlideRecord('sys_user');
getDomain.addQuery('sys_id',gs.getUserID());
getDomain.query();
if(getDomain.location.u_region == 'EMEA' && getDomain.u_ad_domain == 'CTS'){
return true;
}
}
Please mark this response as correct or helpful if it assisted you with your question.