- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-29-2024 07:18 PM
Hello friends,
I was trying to impersonate with certain user using the Glide impersonation APIs using below script. However, I was not able to check in background script if current session is impersonation or not.
Below returned FALSE in every gs.info statement, whereas if same script is executed by externally impersonating i.e. through UI, it returned TRUE always. Any thoughts?
gs.info('FROM BACKGROUND SCRIPT1'+GlideImpersonate().isImpersonating());
gs.info('******************************************************************************');
//gs.print ("The current user name is: " + user);
var currentUser = gs.getUserID();
var impUser = new GlideImpersonate();
impUser.impersonate("62826bf03710200044e0bfc8bcbe5df1");
gs.info('FROM BACKGROUND SCRIPT2'+GlideImpersonate().isImpersonating());
impUser.impersonate(currentUser);
gs.info('FROM BACKGROUND SCRIPT3'+GlideImpersonate().isImpersonating());
Thanks,
Rahul
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-29-2024 07:29 PM
Hi @rahulyamgar ,
check out this post
If my answer helped you in any way, please mark it as helpful or correct.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-29-2024 07:29 PM
Hi @rahulyamgar ,
check out this post
If my answer helped you in any way, please mark it as helpful or correct.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-29-2024 08:23 PM
did you check what came in logs and with which user?
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-29-2024 09:17 PM
Hi there,
It looks to me that the way you scripted this, you are running into a session issue. There for you are just getting false as return.
Kind regards,
Mark Roethof
Independent ServiceNow Consultant
10x ServiceNow MVP
---
~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-03-2024 09:18 AM
You are right- looks like an issue with session. When i added below line for impersonation, it just worked fine. I mean it returned true.
gs.getSession().impersonate("usernameORsysid")
Thanks Mark.