- Subscribe to RSS Feed
- Mark as New
- Mark as Read
- Bookmark
- Subscribe
- Printer Friendly Page
- Report Inappropriate Content
User criteria is a powerful feature that allows you to setup data driven access controls by evaluating the user attributes of a logged-in user. It is extensible enough by allowing you to configure additional user attributes and also provide an advanced script evaluator that could add logic beyond the configurations. They are primarily used for controlling user access on service portals, catalog items, knowledge articles, HR services, HR contents etc. With a proper API, they could be extended further or used in any of your custom implementations.
ServiceNow has an undocumented API named UserCriteriaLoader which is used at multiple scripts within the instance. It can be used to control access and dynamically evaluate a user criteria for your custom solutions. Below, I am explaining all the methods that I was able to discover while using the same for one of my implementation.
var allCriterias = new sn_uc.UserCriteriaLoader.getAllUserCriteria(gs.getUserID());
gs.info(allCriterias);
gs.info(allCriterias.length);
var userCriterias = ['6b6df061ff2121009b20ffffffffff44','0b5b0e6453631300afffddeeff7b1201'];
var userMatches = sn_uc.UserCriteriaLoader.userMatches(gs.getUserID(), userCriterias);
gs.info(userMatches);
var userCriterias = ['6b6df061ff2121009b20ffffffffff44','0b5b0e6453631300afffddeeff7b1201'];
var matchingCriterias = sn_uc.UserCriteriaLoader.getMatchingCriteria(gs.getUserID(), userCriterias);
gs.info(matchingCriterias);
var getCriterias = new sn_uc.UserCriteriaLoader.getUserCriteria(gs.getUserID(),'sc_cat_item_user_criteria_mtom');
gs.info(getCriterias);
Note: The user criterias are by default not overridden by admin users and you will have to explicitly grant them access. Script based user criterias are cached, hence the changes wont reflect unless the user has logged out of the instance.
- 18,704 Views
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.