
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-22-2017 01:23 AM
Hi Community,
The ServiceNow Product documentation for the update function in a GlideRecord is as follows:
As far as I can tell, the reason parameter doesn't seem to do anything despite the documentation.
When I open up the audit history for an update where parameter was called, there is no trace.
Example:
if ( isAnyChildTaskPending() ) {
grParent.state = PENDING_STATE;
} else {
grParent.state = WORK_IN_PROGRESS_STATE;
}
if (grParent.state.changesFrom(previousState)) {
grParent.work_notes = 'Status changed automatically by system to reflect overall status of the request.';
grParent.update('Automation');
}
There is no trace of the 'Automation' in the audit logs that I can find.
I traced it to the sys_audit record - still no reason.
Does the reason parameter actually do anything?
This could be quite useful for tracing automation to business rules.
Thanks,
Paul
ServiceNow Nerd
ServiceNow Developer MVP 2020-2022
ServiceNow Community MVP 2019-2022
Solved! Go to Solution.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-22-2017 08:00 PM
gr.update(reason) does not populate the reason field on the sys_audit record when using task.
This works:
var current = new GlideRecord( 'sc_task' );
current.get('cbbd39274f29f2008d2f87501310c777');
current.state = '2';
current.update('Reason');
This does not work:
var current = new GlideRecord( 'task' );
current.get('cbbd39274f29f2008d2f87501310c777');
current.state = '2';
current.update('No reason');
ServiceNow Nerd
ServiceNow Developer MVP 2020-2022
ServiceNow Community MVP 2019-2022

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-22-2017 07:34 PM
Hi Paul,
Although I can't help you with your specific issue - I found this link the other day when looking for assistance myself with GlideRecords.
https://www.servicenowguru.com/scripting/gliderecord-query-cheat-sheet/
Hopefully it's of some help to you!
Cheers
Carl.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-22-2017 08:00 PM
gr.update(reason) does not populate the reason field on the sys_audit record when using task.
This works:
var current = new GlideRecord( 'sc_task' );
current.get('cbbd39274f29f2008d2f87501310c777');
current.state = '2';
current.update('Reason');
This does not work:
var current = new GlideRecord( 'task' );
current.get('cbbd39274f29f2008d2f87501310c777');
current.state = '2';
current.update('No reason');
ServiceNow Nerd
ServiceNow Developer MVP 2020-2022
ServiceNow Community MVP 2019-2022