Some PDIs are currently unavailable, and PDI actions are paused. View the latest updates here. Read More

Daniele Songini
Tera Guru

Hello everybody,

during tests, it is often necessary to impersonate users who are in the ticket assignment group.
To speed up this operation, I created an UI Action, which allows you to impersonate a (random) user of the assignment group.

find_real_file.png


A message indicates which user was impersonated

find_real_file.png


This is the UI Action

Name: Impersonate user in group

Table: Catalog Task (select the desired table)

Condition: 

current.assignment_group && ( gs.getUser().hasRole("impersonator") || gs.getImpersonatingUserName() != "" )


Script: 

// Retrieve user in group
var gr = new GlideRecord("sys_user_grmember");
gr.addQuery("group",current.assignment_group);
gr.addQuery("user.active",true);
gr.addQuery("user.sys_id","!=",gs.getUserID()); // Me
gr.setLimit(1);
gr.query();

// Impersonate
if(gr.next()){
	session.onlineImpersonate(gr.user);
	gs.addInfoMessage("Impersonated: " + gr.user.name);
	action.setRedirectURL(current);
} else {
	gs.addInfoMessage("No user impersonated! Please check the members of the group");
}


I hope it's useful!
Corrections and comments are welcome 🙂

Daniele

Comments
JohnQ1
Tera Contributor

Good idea!

OtaS2209
Tera Contributor

Hi, I like it. Only I am missing a button/link to end impersonation.

 

A person is impersonated, but I still see the admin account in the top right corner. So it could be confusing.

Adam Cartrette
Tera Expert

This is a good idea. Ultimately I would prefer the Impersonate User be expanded to include using criteria like group and roles. 

New Developer_S
Giga Sage

@Daniele Songini 

its a nice implementation. But how to end this impersonation ? Have you also worked on any solution for this ?

 

 

Version history
Last update:
‎12-09-2019 09:16 AM
Updated by: