Old value/New value of every field on the form
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-30-2017 07:06 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-30-2017 07:28 AM
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>