How to update RITM work notes with the old and new field values throuh flow designer.

Suresh_32
Tera Expert

 RITM work notes should be updated with the all the fields when we make the changes on the catalog fields and it should be in the below format. 

"The fieldname is changed from old value to new value"

Please find the below catalog form fields :

Suresh_32_0-1743181906824.png

when we are trying to update one field Group Manager value from "Chloe Campbell" to 'Karthik C", the RITM work notes should be updated with the below format.

The Group is updated:
Group Name CISO GLBL ACTIVE DIRECTORY INFRASTRUCTURE APPROVAL

The Group Manager is changed from Chloe Campbell to Karthik C.

The Description is changed from old value to old value(even they have not changed Description) like this for all the fields.

 

Now the RITM work notes is updated with the current value only (updated Group Manager value)

 

Suresh_32_1-1743182494490.png

 

Please see the below existing flow designer configuration.

Suresh_32_2-1743182834315.png

Please help me how do we can make the changes in flow designer.

 

 

 

 

7 REPLIES 7

lpruit2
Kilo Sage

Greetings,

 

I have personally never done this and when I researched Flow Designer "previous values" I found a ServiceNow Knowledge Base article that states Flow Designer is not the best use-case for capturing current and previous values. They recommend a Business Rule which has access to current and previous. If you were interested in a low-code solution you could create a Subflow with inputs for: ticket number, field name, previous value, and current value. You could then create a simple Business Rule that captures those values from the ticket the change is made on and then calls the Subflow and passes those 4 parameters/inputs. 
Can flow designer determine the previous and current value of a field? - Support and Troubleshooting

Rohit  Singh
Mega Sage

Hi @Suresh_32 ,

 

You have to use after Business Rule, so that you can bring the previous and current value of a variable.

 

I don’t think from Flow you can get the previous value of variable.

 

If my response helped, then please accept the solution and hit thumbs up. This will help future readers as well.

 

Regards,

Rohit

Thank you for your reply Rohit,

If possible, could you please send me with the code.

Ankur Bawiskar
Tera Patron
Tera Patron

@Suresh_32 

Not possible using flow designer

for that please use before update business rule on sc_req_item table

Condition: current.cat_item.name == 'Your Item Name' && current.variables.changes()

Script:

(function executeRule(current, previous /*null when async*/ ) {
    var question, prv1, cur1;
    var cur = current.variables.getElements();
    var pvr = previous.variables.getElements();
    var arr = [];
    for (var i = 0; i < cur.length; i++) {
        if (cur[i] != pvr[i]) {
            question = cur[i].getQuestion().getLabel();
            cur1 = cur[i]; // current value
            prv1 = pvr[i]; // previous value
            var str = 'The ' + question + 'has changed from ' + prv1 + ' to ' + cur1;
            arr.push(str + '\n');
        }
    }
    current.work_notes = arr.toString();

})(current, previous);

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader