logo

NJP

Faster (Un)Impersonating

Import · Nov 30, 2020 · article

image

When implementing a complex rights and roles concept, it is often necessary to use the impersonate function of ServiceNow for testing the correctness of the rights adjustments. And even as a service desk agent, it is often necessary to impersonate as the ticket creator in for reproducing the described problem. Therefore, it would be really helpful, if impersonating could be triggered just by one click.

But even impersonation takes time and every additional click adds up to a considerable amount at the end of the day.

Faster Impersonating

To accomplish this, I developed a new UI action "Impersonate" for the sys_user and sys_user_has_role tables, which can be used in both the list view and the record view to trigger an impersonation in a new browser tab.:

image image

However, the most useful feature is the UI Macro "impersonate_user" that can be used on any field with a reference to the sys_user table, for example at field "Caller" on Incident records:

image

To configure the UI Macro at the desired field:

  1. Right-click on the field label and choose "Configure Dictionary":
    image
  2. Add dictionary attribute "ref_contributions=impersonate_user". If the "ref_contributions" attribute already exists, the macro name can be added separated with a semicolon, for example "ref_contributions=user_show_incidents;impersonate_user":
    image

Faster Unimpersonating

While impersonating a user, it would be helpful to unimpersonate with a singe click only, for example via a link or icon in a central place.

In my article Inject a custom icon into the header bar of the Next Experience UI I have demonstrated how you can offer functionalities in a central place - the header bar - and for a faster unimpersonating I reused that idea.

With the help of an additional UI Script a crossed-out eye icon is injected into the header bar to allow unimpersonation with a single click:

image

How to get everything

All required artifacts are bundled in an Update Set published on Share: https://developer.servicenow.com/connect.do#!/share/contents/4067296%5Ffaster%5Fimpersonating.

View original source

https://www.servicenow.com/community/now-platform-articles/faster-un-impersonating/ta-p/2322155