
- 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 01:37 AM
Hi Paul,
Thank you for your post.
Can you confirm if you have added in the "Reason" field to the form layout on the sys_audit table? Based on the screenshot you have provided, I am unable to see the "Reason" field on the form
You can do this via the following:
1. Navigate to sys_audit.list on the navigation bar on the instance
2. Right-click > Form Layout and select "Reason", then click "Save"
Best Regards,
Arron

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-22-2017 06:27 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-22-2017 07:31 PM
This worked perfectly for me. I wasn't aware of this functionality but I'll certainly use it!
var gr = new GlideRecord( 'incident' );
gr.get( 'sys_id', '53adb1e3dbed76005587f7951d961916' );
gr.short_description = 'new';
gr.update( 'solid reason, mate' );
Might be worth a HI ticket at this point...

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-22-2017 07:47 PM
I ran your code and confirm it works.
However, my code definitely is not.
I even copied the business rule into a background script and executed it, and the reason field is still empty.
ServiceNow Nerd
ServiceNow Developer MVP 2020-2022
ServiceNow Community MVP 2019-2022