- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-21-2016 04:30 AM
Hello.
GlideRecord wiki page tells
public string update(Object reason)
Parameters: reason - Takes a string designating the reason for the update if necessary. The reason will be displayed in the audit record.
So what is right way of providing reason?
Neigher
var gr = new GlideRecord('alm_hardware');
gr.get('0034748c0ffc02003685ee68b1050e70');
gr.setForceUpdate(true); //just to make sure
gr.comments = 'test123'
gr.update("reason text her")
no
var gr = new GlideRecord('alm_hardware');
gr.get('0034748c0ffc02003685ee68b1050e70');
gr.setForceUpdate(true); //just to make sure
gr.comments = 'test1232'
var reason = {'reason' : 'some reason here'}
gr.update(reason)
works for me.
Thanks.
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-21-2016 07:07 AM
Both hard-coded strings and string variables will work (although your first example is not a string but a JavaScript object). However, the reason is NOT added to the History table (sys_history_line), which the Activity Formatter uses to display in the form, but it is added to the Sys Audit table (sys_audit), which is not really shown anywhere. You'll probably have to personalize your list view to add the Reason column.
It's definitely a little misleading.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-21-2016 05:16 AM
try only gr.update(); or
var reason='try';
gr.update(reason);
Also is audit on for that table .?
Mark Correct if it solved your issue or hit Like and Helpful if you find my response worthy.
Thanks,
Deepa
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-21-2016 06:11 AM
only gr.update() will not give me the reason.it will just write changes to history
Deepa Srivastava wrote:
Also is audit on for that table .?
Table dictionary entry has audit option ticked
And there is picture of history changes for
var gr = new GlideRecord('alm_hardware');
gr.get('0034748c0ffc02003685ee68b1050e70');
gr.comments = 'some new coments'
var reason='try';
gr.update(reason);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-21-2016 06:34 AM
Hi,
With gr.update() method you will update the current record of that table to which it has queried.
And if you use gr.update('some reason mentioned'); this will update with the reason mentioned in the audit table.
If this need not be tracked via history table you can add
autoSysFields(false);
Thanks and Hope it helps.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-21-2016 07:07 AM
Both hard-coded strings and string variables will work (although your first example is not a string but a JavaScript object). However, the reason is NOT added to the History table (sys_history_line), which the Activity Formatter uses to display in the form, but it is added to the Sys Audit table (sys_audit), which is not really shown anywhere. You'll probably have to personalize your list view to add the Reason column.
It's definitely a little misleading.
