How to use User Criteria as a condition in a script

rlatorre
Kilo Sage

We would like to test against User Criteria definitions in the condition of a business rule, UI action, client script, etc.

Is there a way to script to test against User Criteria definitions and return true or false?

1 ACCEPTED SOLUTION

Chuck Tomasi
Tera Patron

Hi Robert,



There is a class/method to use to tell you which criteria apply. I have not yet figured out a way to evaluate each of those. Do some experimenting - i'm curious to know more.


 


SNC.UserCriteriaLoader.getAllUserCriteria()


Returns an array of sys_ids of the user criteria available to you. (applies to user's current login session.)


View solution in original post

9 REPLIES 9

Thanks for the response Chuck. Here's a simple use case I think should explain:



If the user in the field "Caller" on an incident matches a certain User Criteria record I want to perform an action such as increase Escalation.


You are probably going to have to write a script of your own to get that specific. As far as I know, the User Criteria functionality checks the currently logged in user only.


Thank you Chuck. You have been very helpful.


Sunny24
ServiceNow Employee
ServiceNow Employee

Were you able to solve this? I'm having trouble doing a user criteria check for the caller on the incident form via client script. I would like an alert to display. 

johnmark
ServiceNow Employee
ServiceNow Employee

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

Semaphores keep getting stuck and cause slow performance due to UserCriteriaLoader.getAllUserCriteri...