- Post History
- Subscribe to RSS Feed
- Mark as New
- Mark as Read
- Bookmark
- Subscribe
- Printer Friendly Page
- Report Inappropriate Content
on 07-03-2019 02:06 AM
I recently came across a requirement from a customer for limiting the available request items for selection when transferring a call to a request based what items the caller populated in the caller field had access to.
This meant applying user criteria to the user populated on the record rather than the logged in user in the 'Request Item' reference qualifier.
In order to achieve this I utilised the User Criteria Scoped API
https://developer.servicenow.com/app.do#!/api_doc?v=madrid&id=UCLS-getAllUserCriteria
Along with a script include + reference qualifier combo
Finished script below:
function call_req_items(){
var allowedItems = '';
var caller = current.caller.sys_id; //the user populated in the call
var result = new sn_uc.UserCriteriaLoader.getAllUserCriteria(caller);
for(var i = 0; i < result.length; i++){
var reqItems = new GlideRecord('sc_cat_item_user_criteria_mtom');
reqItems.addQuery('user_criteria', result);
reqItems.query();
while (reqItems.next()){
allowedItems += (',' +reqItems.sc_cat_item.sys_id);
}
return 'sys_idIN' + allowedItems;
}
}
Important.
The plugin User Criteria Scoped API plugin must be activated for this to work
- 762 Views
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Thanks for this which pointed me in the right direction.
I was able to modify the reference field to "Use reference qualifier" and then provide the following Reference qual:
javascript:'active=true^user_criteria=' + new sn_uc.UserCriteriaLoader.getAllUserCriteria(current.caller) + '^EQ'
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
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
Below are additional Knowledge articles which discusses Semaphore Exhaustion caused by the getAllUserCriteria function being called in widgets:
Semaphore Exhaustion is caused due to the getAllUserCriteria function getting called in widgets