Impersonating a user from a server script (ServiceNow)

I recently needed to add a bunch of work notes to old incidents, but the comments needed to show up as being posted by someone else. This worked quite handily:

var impUser = new GlideImpersonate();
impUser.impersonate('6816f79cc0a8012341c5a33be123beaa1');

The sys_id in the code will obviously need to be changed to the user in your environment that you’re wanting to impersonate.

Leave a Reply