User criteria to restrict by country shown in user location
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-13-2017 05:48 AM
How would I format a script to restrict to a location's country value based on a users location record.
I am using Country to limit who can see certain things in the Service Catalog, and having trouble getting it to pull the right info.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-13-2017 06:33 AM
use dot walking in the catalog entitlement script to restrict in servicenow. See the following link.
lets see the following script which shows a catalog for a user in South Africa
var userid = gs.getUserID();
var gr = new GlideRecord('sys_user');
gr.get(userid);
var fullLocation = gr.location.full_name;
if ( fullLocation.indexOf("South Africa") > -1 )
{
answer = true;
}
else
{
answer = false;
}
Legacy:Service Catalog Access Controls - ServiceNow Wiki
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-13-2017 06:52 AM
The new way in ServiceNow is to use User Criteria, and in this circumstance, I would use the advanced script. Would this change anything with your script approach?
Also, using the service Portal, would this scripting work?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-13-2017 07:41 AM
I think the User Criteria functionality is available only on Knowledge Application
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-13-2017 07:47 AM
No, User Criteria is used for catalog items as well. We are using it today, but it makes no sense to add every location manually to the location filter when you can script out to use the country code. One of the other challenges with the script is you cannot use the glide record functionality on the Service Portal, you have to change your scripting to call a function in a script include.