User Criteria not working other than Logged In Users

inspiron
Kilo Contributor

I want to use user criteria for some other user rather than the logged in user. My requirement is I have to pass user sysid according to the requested for field value. I have stord that requested for field value in session variable and then using it in User criteria Advanced script section but it's not working. Even for the testing purpose I have hardcoded the sys_id of a user but still it is not working.

Can we pass users dynamically in Advanced Script in User Criteria?

Please suggest me any solution.

Thanks,

Surbhi

4 REPLIES 4

naveenaechan
ServiceNow Employee
ServiceNow Employee

Hi,



Look at the thread below, which talks about scripting for User Criteria.



Advanced Script for User Criteria



Also can you share the script, so that we can suggest more.




Thanks


Naveen



PS: Hit like, Helpful or Correct depending on the impact of the response


Hi Naveen,



Below are the scripts that I am using.



I have set the value of session and then fetching in the user criteria.




User Criteria :



answer = false;


var session = gs.getSession();


var userID = session.getClientData('test1');


gs.log("userID   :   " + userID );



When I am checking the log after opening the item It's not showing but if I am impersonating the another user it's showing log with value "null" because session is not existing after impersonation.



Thanks,


Surbhi


Miriam Berg
Kilo Guru

Hi there!



I had the same question and for me and my group it wasn't working because of the user criteria caching! So even though we had a User Criteria script, it was only evaluating when it was not already cached - for example when logging in with another user.



For us it started working after we tried updating the user record immediately after changing the sys_id that we sent to session.getClientData, and also reloading the page, both things done from the widget. Updating the user record forced a re-evaluation of the user criteria, and reloading the page made the changes show.



Best Regards,


Miriam


Hi Mariam, I'm facing the same issue and trying to get it to work properly via the GlideSession. Can you please show me the scripting part of your solution? Thanks in advance.