Making a GlideRecord insert/update appear to from SYSTEM or another user
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-14-2012 10:43 AM
This is something small that's been annoying me for awhile; I have dozens of server-side background scripts in various modules that insert/write to their related tables via GlideRecord(). When they are ran; the update/insert is listed as the user who initiated the script. In most cases this is fine; but in a few cases I actually would like the script to appear to have ran as SYSTEM when it writes to fields such as work notes.
.sys_updated_by doesn't do what I need it to do, and .opened_by only works on inserts not updates.
Example:
Output:
11-14-12 10:23:29 AM Smith, John - Changed: Work Notes
some notes
What I want it to do:
11-14-12 10:23:29 AM SYSTEM - Changed: Work Notes
some notes
var gr = new GlideRecord('incident');
gr.get('number','INC00000');
gr.work_notes = 'some notes';
// gr.sys_updated_by = 'some user'; // Updates the sys_updated_by field; but not the activity / history
// gr.opened_by = 'some user'; // Only works on inserts
gr.update();
Even though John Smith initiated the script; I need the record to show that system ran it.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-30-2012 07:53 AM
Thank you Chris!! [gs.getSession().impersonate(ugr.sys_id)] is exactly what I needed.
Thanks again!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-30-2012 11:50 AM
Thanks, Chris for posting that. I don't know why I didn't think of that...
Nick, if you're satisfied, be sure to mark the thread "Answered" so those searching the Community can find it.