logged in user roles in UI policy

ryadavalli
Tera Expert

I have to check If the logged in person is different than approver in an UI policy, how can I achieve this ?

6 REPLIES 6

Chuck Tomasi
Tera Patron

Hi Ravali,



Try this:



Approver | is not | javascript:gs.getUserID()



I did this on incident to see if the logged in user is NOT the caller.



find_real_file.png


Perfect Chuck. Thanks, can I also logged in person has change_manager role also as a part of UI policy?


For that you would need to go to a client script. The condition might look something like this:



if (g_user.hasRole('change_manager'))


// do some more stuff



To translate the UI policy condition in to a client script



if (g_form.getValue('caller_id') == g_user.userID)


// do some stuff



Reference:


GlideUser (g user) - ServiceNow Wiki


GlideForm (g form) - ServiceNow Wiki   and for good measure to keep you from hurting yourself...


Client Script Best Practices - ServiceNow Wiki


Yeah I understand that it could be addresses using a client script, but my problem is as UI policy executes after client script, what ever mandatory client script sets, they are wiped by another Ui policy's false condition, so I am trying to make it a part of the that UI policy.