Shane J
Tera Guru

After a lot of debugging and numerous searches on the Community, I wanted to post what seems to be the only working solution I've been able to come up with for using User Criteria to limit something via a Condition, such as a Header Menu via the Service Portal.

SNC.UserCriteriaLoader.getAllUserCriteria().toString().includes("sys_id_of_the_User_Criteria_record")

Note that you don't need the User Criteria for the Service Portal plugin for this to work.

Comments
suladance
Kilo Expert

Hey @Shane J, just wanted to say thanks for this post. Really helpful, would be good if ServiceNow expanded User Criteria to tables like this, but this is an excellent workaround.

Shane J
Tera Guru

Happy to help, suladance.  😃

Taha6
Tera Expert

Exactly what I was looking for 🙂
Thanks, Shane!

Alex87
Tera Contributor

do you know how it works with in combination of the HR criteria?

sturton
Tera Guru

Thanks Shane! Exactly what I was looking for, will save me updating user criteria in multiple areas

Mafoa Mafoa1
Tera Explorer

Thank you so much!

 

tobbasp
Tera Contributor

If anyone has this problem and the provided solution is not working, try the following:

sn_uc.UserCriteriaLoader.getAllUserCriteria(gs.getUserID()).toString().includes("sys_id_of_user_criteria")

Teresa Carvajal
Giga Guru

Thank you so much @tobbasp  - your solution works for me!!

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

Version history
Last update:
‎02-12-2020 09:09 AM
Updated by: