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

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.)


I knew I could count on you Chuck.



With this I would create a script include that would return the sys_id of a User Criteria record that I want to test against. Then see if that sys_id is contained in the array returned by SNC.UserCriteriaLoader.getAllUserCriteria().



Like:


SNC.UserCriteriaLoader.getAllUserCriteria().indexOf(getUserCriteraFromName("Users at Corporate Locations")) > -1


I had one more question on this and I hope you can help me. Below will allow me to script against if the logged in user meets a certain User Criteria but what if I want to see if a user is a reference field meets the criteria?



SNC.UserCriteriaLoader.getAllUserCriteria().indexOf(getUserCritera_name("Users at Corporate Locations")) > -1



getUserCritera_name("Users at Corporate Locations") returns the sys_id of the User Criteria record


Hi Robert,



I'm not clear what your objective is. Can you clarify this?



what if I want to see if a user is a reference field meets the criteria