Old value/New value of every field on the form

Dawid2
Giga Guru

Hello,

Is there a way to list previous value and new value into the script of Business rule? I'm currently utilizing following script:

if (current.manager.changes()){

              var manOne = previous.manager.getDisplayValue();

              var manTwo = current.manager.getDisplayValue();

              listOne = 'Manager has changed from ' + manOne + ' to ' +manTwo;

However, since we have so many fields on the form, I would like to use something simpler and not to list every field separately. I would also like to maintain the form of "[Field Name] has change from [previous value] to [new value]". Can this be achieved?

Thanks.

5 REPLIES 5

Uncle Rob
Kilo Patron

There's a utility that can help you with that:   GlideScriptRecordUtil.   It stores the fields and values of changes on an update.


The incomparable mark.stanger provides a great example of its use on ServiceNowGuru.



Essentially, you use GlideScriptRecordUtil to pump the update results to an array, then you loop through the array.   Thus, you <do what's needed> only on <things that were updated>