How to limit users in impersonation

Community Alums
Not applicable

Hi Team, how can we limit the users to be selected in impersonation window? We have a requirement to allow only approved users to be available for impersonators to impersonate.

1 ACCEPTED SOLUTION

Community Alums
Not applicable

Thank you @iamkalai, I have used below condition in before query BR on sys_user table, and it works.

Condition: gs.getSession().isInteractive()  && gs.action != ''

Script: if ((gs.action.getGlideURI().toString()).indexOf('impersonate') != -1 || (gs.action.getGlideURI().toString()).indexOf('angular.do?sysparm_type=ref_list_data') != -1) {

  <YOUR CODE GOES HERE>

}

 

NOTE: Do not add above if condition in the condition field, orelse you will get java null pointer exception while updating record in sys_user table.

View solution in original post

17 REPLIES 17

SMR1
ServiceNow Employee
ServiceNow Employee

This didn't work for me, could you please provide an example?

Community Alums
Not applicable

Can you tell me your code?

Hi, This solution works, but if you really want to restrict Impersonation to only one session and one has already impersonated a user. The impersonated user is shown as Recent Impersonations. Is there a way to reset that entry ?