- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-03-2016 11:06 PM
Is there any way to evaluate whether a user meets a user criteria inside code (Such as a custom Script Include)?
I have found GlideappCatalogItem & GlideappCategory that can evaluate if something's visible, but they're java classes so I can't see what's under the hood. What I'd really love to be able to do is take a user_criteria & get back a true/false for the current user.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-18-2017 10:07 AM
You can return a list of user criteria records the the logged in user matches sever side using:
SNC.UserCriteriaLoader.getAllUserCriteria()
I created a script include to return the sys_id of a user criteria record to do the test:
getUserCritera_name(
"name_of_user_criteria_record")
I use this as a condition:
SNC.UserCriteriaLoader.getAllUserCriteria().indexOf(getUserCritera_name(
"Users at Corporate Locations"
)) > -1
I'm currently working on a script include to evaluate client side as well as against any user sys_id not just the logged in user.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-09-2017 08:42 AM
Martin,
We use impersonate in some integrations and we revert back to system. Would this be necessary for this application?
logger.logDebug('onAfter processing - Turn off Impersonation. Going back to \"system\"', null, null);
gs.getSession.impersonate('system');

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-19-2017 03:43 AM
Hello Robert,
I'm not sure, but I think it will do no harm so I would revert back to system just in case.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-21-2018 12:45 PM
This solution is what I've been doing for awhile now, but have come to find out that it fails if executed as a user who does not have the impersonator or admin role.
Use case: our Service Desk is trying to view catalog items that are available for their current caller. My script include impersonates the caller, runs through the catalog and determines what they have access to. It works fine if an admin or user with the impersonator role tries this, but the Service Desk does not have these roles.
Any ideas on how to impersonate server-side regardless of the logged in user's permissions?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-27-2025 11:41 AM
UserCriteriaLoader.getAllUserCriteria() method is a deprecated method and we advice using userMatches() instead.
☞ Please refer to this article below, which explains on this in detailed.
https://www.servicenow.com/community/now-platform-blog/a-deep-dive-to-user-criteria/ba-p/2281285