
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-27-2016 11:18 AM
Is it possible?
Or may be there is an other workaround for my case.
What i am trying to do:
some of my RITMs could only be created automaticly. Let me call them child RITM.
I have a busines rule with logic: after a child RITM is created it find a parent RITM and copy watch list and comments/work notes from it to child.
Here is a thing a don't like: all copied comments are created by user that triggered business rule.
I would like them to be created by some other user named "System".
Thanks
Solved! Go to Solution.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-28-2016 03:13 AM
So no way to do something like "impersonate while updating" ?
Updating of one Scheduled Script Execution is potential sourse of problem in cause of concurrent updates.
But thank for idea it lead me to ScheduleOnce that runs update as System user.
So my current solution is to move all logic to script and cal it with ScheduleOnce.
var so = new global.ScheduleOnce();
so.script = "new SomeScript().someMethod('" + current.sys_id + "')";
so.schedule();
upd. Here is an example how to impersonate and save as any user:
var gr = new GlideRecord('sc_req_item')
gr.get('34069d870fc6ee003685ee68b1050ed9')
gr.comments = "test comments"
gr.work_notes = "test worknotes"
//now impersonate saving original user id
var origUser = gs.getSession().impersonate('161ce02e4f166640e11fe3414210c76b');
gs.print(origUser)
gr.update("impersonate testing")
//switch back to original user
var impersonated = gs.getSession().impersonate(origUser );
gs.print(impersonated)

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-27-2016 06:43 PM
A Scheduled Script Execution has a Run as field for specifying a User. You could try using your Business Rule to update a Scheduled Script Execution, then execute the script from the BR.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-28-2016 03:13 AM
So no way to do something like "impersonate while updating" ?
Updating of one Scheduled Script Execution is potential sourse of problem in cause of concurrent updates.
But thank for idea it lead me to ScheduleOnce that runs update as System user.
So my current solution is to move all logic to script and cal it with ScheduleOnce.
var so = new global.ScheduleOnce();
so.script = "new SomeScript().someMethod('" + current.sys_id + "')";
so.schedule();
upd. Here is an example how to impersonate and save as any user:
var gr = new GlideRecord('sc_req_item')
gr.get('34069d870fc6ee003685ee68b1050ed9')
gr.comments = "test comments"
gr.work_notes = "test worknotes"
//now impersonate saving original user id
var origUser = gs.getSession().impersonate('161ce02e4f166640e11fe3414210c76b');
gs.print(origUser)
gr.update("impersonate testing")
//switch back to original user
var impersonated = gs.getSession().impersonate(origUser );
gs.print(impersonated)

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-28-2016 04:02 AM
"Run as" is exactly "impersonate while updating".
I haven't seen ScheduleOnce before. That's a good one to know.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-09-2016 04:18 AM
Hey Geoffrey, I have found a way to impersonate without "Rus as". Please take a look at my updated answer