- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-19-2015 08:25 AM
Greetings!
I have been trying to figure out a way to run a Business Rule in it's entirety as a user other than myself, or the user who has triggered the BR. Here is an example:
When work notes and customer notes are updated on an Outage, I have a BR that pushes those notes updates to the incidents associated with the outage. The notes in the associated incidents naturally show as me who added them. However, what we would like to do is show that a specific user (in this case a user named "System Update") actually added them instead.
Does anyone have a solution on how to do what I'm detailing? Any help is very much appreciated. Thanks!
Jeremie
Solved! Go to Solution.
- Labels:
-
User Interface (UI)

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-30-2017 06:38 AM
Depending on where your request is originating, you can do this using an 'async' business rule. Being asynchronous, it temporarily pushes the script in the rule to the background. When it brings it back to the foreground, it's running as user 'system'. 'System' has the innate ability to impersonate. So, combining scripted impersonation with the 'system' account, you can write an async rule like this:
var journalGR = new GlideRecord('sys_journal_field');
journalGR.addQuery('element_id', current.sys_id);
journalGR.orderBy('sys_created_on');
journalGR.query();
while (journalGR.next()) {
var convertedTask = new GlideRecord('task');
convertedTask.get(current.u_converted_to);
var userGR = new GlideRecord('sys_user');
userGR.get('user_name', journalGR.sys_created_by);
var originalUser = gs.getSession().impersonate(userGR.sys_id);
convertedTask[journalGR.element] = journalGR.value.toString();
convertedTask.update();
gs.getSession().impersonate(originalUser);
}
Our use case was to convert 'tickets' to other task types like incident and FMRs. This includes some extra code that you probably don't need that collects the journal entries of the ticket and puts them in the new task as the user who originally created them.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-19-2015 11:02 AM
Agreed; all good ideas but each with a caveat. Is this something that ServiceNow could help with, or could this be seen as a potentially frivolous request?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-19-2015 11:08 AM
No request is a frivolous one that meets a business requirement. This is not the first time I have heard a request for a "Comment on behalf of" type feature. I would say submit an enhancement request or perhaps an incident and see what they say. You can always use the community, Knowledge Conference, and SNUGs to rally support for an idea. Who knows, someone who has yet to see this post may even have a solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-19-2015 12:19 PM
Good points. Thank you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-05-2016 01:55 PM
Hi Jeremie, Did you find answer for this because i trying to do the same thing with the scheduled jobs! Please let me know if you find one (need coding basically). Thanks!
- Prabeen
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-07-2017 10:51 AM
Hi Jeremie,
Have you tried logging in as your default 'admin' or another more generic account with admin rights to create the Business Rule? This will change the created_by to that account instead of you. Give it a try...
Mike