Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

What is right way of providing update reason?

Igor Kozlov
Tera Expert

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.

1 ACCEPTED SOLUTION

Jim Coyne
Kilo Patron

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.


View solution in original post

8 REPLIES 8

Thank you. This information is very helpful.   Btw do you know why there is no "Correct answer" button so i can't mark your post with it?


click on the below link to find it.



What is right way of providing update reason?


Mark Correct if it solved your issue or hit Like and Helpful if you find my response worthy.


Thanks,
Deepa


Looks like the post was not originally marked as a question.   I think dan.bruhn can help with that.


Hi Jim,



I went ahead and updated the thread.



Thanks,