how can I impersonate a user via script

amarmohamad
Giga Contributor

how can I impersonate a user via script

1 ACCEPTED SOLUTION

vab_13
ServiceNow Employee
ServiceNow Employee

gs.getSession().onlineImpersonate("<user_name>");


View solution in original post

6 REPLIES 6

amarmohamad
Giga Contributor

Thanks All


Priyanka95
Kilo Contributor

I have tried all of them but its not working in my case.

My case: I am using this in a runscript of a workflow where I am trying to update one of the sctask of the request item with the impersonated user. But the update is happening with the user who raised the request. And if I update the request item, it is updated with impersonated user.

So the issue is when I am gliding the sctask that was already created and updating the record.

Is there something I am missing. PLease help.

I have tried gs.getSession().onlineImpersonate("<user_name>");,new GlideImpersonate().impersonate(your user id);etc

The impersonate log says it is sussesfull but still the update is not with impersonated user.