Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

impersonating

yoli1
Tera Contributor

Hi All how can i know if the user is impersonated? this doesn't work gs.getSession().Isimpersonating() i get this error : 

Illegal access to getter method isImpersonating in class com.glide.sys.GlideSession
2 REPLIES 2

Dr Atul G- LNG
Tera Patron
Tera Patron

Hi @yoli1 

 

https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0717055

 

*************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.

Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]

****************************************************************************************************************

Tai Vu
Kilo Patron
Kilo Patron

Hi @yoli1 

Let's use this API below to determines whether the current user is impersonating another user.

isImpersonating()

Returns
Type Description
BooleanTrue: User is currently impersonating another user.

False: User is not currently impersonating another user.

 

Sample.

 

function abortOnImpersonate() {
    if (GlideImpersonate().isImpersonating()){
  current.setAbortAction(true);
  gs.addInfoMessage("Transaction canceled due to Impersonation");
    }
    return;
}

 

 

Cheers,

Tai Vu