GlideImpersonate - how to end user impersonation using impersonate()Issue Developers using GlideImpersonate in script actions or business rules need to end user impersonation after completing operations under the impersonated context but cannot find a dedicated method such as unimpersonate() to do so. Symptoms User impersonation remains active after the intended operation completesEvents or notifications processed after impersonation begins are attributed to the impersonated user instead of the expected usernotification_engine.process or other events stamped with an unexpected user due to impersonation not being endedSystem logs show operations running under an unintended user contextHR Workspace or other views display incorrect user attribution on interactions or email activity Facts The GlideImpersonate API does not have an unimpersonate() methodThe impersonate(String userSysId) method returns the 'sys_id' of the user that was logged in prior to the impersonation callTo end impersonation, impersonate() must be called again using the previously returned 'sys_id' to restore the original user contextIf impersonation is not properly ended, any subsequent operations in the same session, including event processing and notification engine actions, will run under the impersonated user's contextThis can cause system events such as notification_engine.process to be processed under the wrong user, resulting in incorrect attribution in views such as HR Workspace Release All supported releases Cause The GlideImpersonate API is designed so that impersonate() both starts and ends impersonation through the same method. Calling impersonate() without saving the returned 'sys_id' and calling it again to restore the original user leaves the impersonation active for the remainder of the session, affecting any subsequent operations, including event and notification processing. Resolution To properly start and end impersonation in a script, save the return value of the first impersonate() call and use it to restore the original user context: var impUser = new GlideImpersonate(); // Save the original user's sys_id returned by the first impersonate() call var originalUserSysId = impUser.impersonate("<target_user_sys_id>"); // Perform operations under the impersonated user context here // Restore the original user by calling impersonate() again with the saved sys_id impUser.impersonate(originalUserSysId); Important Notes: There is no unimpersonate() method in the GlideImpersonate API - this is the expected and only supported approach for ending impersonationValidate any impersonation changes on a non-production instance before deploying to productionThe system records all actions performed during impersonation as having been done by the impersonated userImpersonation should only be used for testing and should not remain active beyond the intended operation Related Links GlideImpersonate API - ServiceNow Documentation