How to show alert message when we impersonate to other user and try to update any record

Pallavi K1
Kilo Guru

We usually impersonate to other user to check any issue reported by that user. Later we forget that we are on impersonation and update other records unrelated to this user which will update the impersonated users name in the time stamps.

To avoid that , can we show an alert message whenever we try to update any record with impersonation. I see from docs that we can know the impersonated user and whether we are on impersonation with OOB functions. But where to write this script, for it to apply for all updates in the instance

6 REPLIES 6

Mike_R
Kilo Patron
Kilo Patron

Are you talking about in production or sub-prod?

Hello Mike, I am talking about Production

 

kamlesh kjmar
Mega Sage
Mega Sage

Hi @Pallavi K1 ,

 

Mostly this happens on any task record. So, I would so you how you can do it on any task record be it incident/prob/change/req:

 

1. Write a Display BR on task table with below script:

 

 

 

 

 

 

(function executeRule(current, previous /*null when async*/) {

	// Add your code here
	g_scratchpad.isImpersonated = GlideImpersonate().isImpersonating();
	

})(current, previous);

 

 

 

 

 

 

kamleshkjmar_2-1667224507856.png

 

2. Write a client script on task table with below code:

 

 

 

 

 

 

 

function onSubmit() {
   //Type appropriate comment here, and begin script below
	if(g_form.modified && g_scratchpad.isImpersonated){
		alert("You are imporsonated with other user's account");
		return false;
	}
   
}

 

 

Make sure inherited check box is check on your client script:

 

kamleshkjmar_3-1667225113913.png

 

 

 

Now when you try to make any change it will pop up the alert and won't save anything

kamleshkjmar_1-1667224468822.png

I Hope this helps.

 

Please mark this helpful if this helps and mark as correct if this solves your issue.

 

Regards,

Kamlesh

 

 

Hi @Pallavi K1 ,

 

Could you please update if your query is resolved? If yes, could you please help us close this thread by Accepting the appropriate response as solution so that it could help others with similar issue.

 

Regards,

Kamlesh