When does user criteria run?

theiser
Tera Expert

I have a requirement that allows a user to change the business area they are supporting which will then load the appropriate categories/catalog items. To do this I created a widget that allows them to select their appropriate business area which will then update a user preference. I have a user criteria record created that uses the script to check the user preference. It works when the user first logs in, however if they change their business area and the page reloads the user criteria does not pick up on the change. This leads me to believe that all user criteria analysis is performed when a user logs in and at no other time. I have even used SNC.UserCriteriaLoader.getAllUserCriteria() to see the latest changes after they applied the business area and the user preferences are updated.   Is there a way to manually kick off the user criteria analysis?

4 REPLIES 4

Brad Tilton
ServiceNow Employee
ServiceNow Employee

Hi Timothy,



I think the user criteria gets evaluated whenever the page loads, but I think you're issue is using user preferences. In order to get the user preference to kick in you have to log out and back in, so you may be better off keying off something else. Maybe using a user attribute or another table.


I'm not sure that it does. I am testing this while using the company user criteria. I am also impersonating a user. I have two separate browsers open, one where I am admin and will update the user profile and the other where I impersonate the test user. If I update the profile company and refresh the test user it does not pick up on the new company.


Matt Hernandez
Tera Guru

Tim,


Were you able to succeed in this with user criteria and user preference updates? I found your post because we are trying this same thing and having the same issue. Did you find a better way to do it, or did you succeed this way?


Aleksas Kucins1
Giga Expert

Hi,

If user criteria is not refreshed with logging out and back a cache refresh with cache.do should fix that.

However you can create a workaround to refresh user criteria immediately without the need to log out and back in.

See link at my blog: https://servicenowthink.wordpress.com/2019/04/07/apply-effects-of-user-criteria-without-the-need-to-...