OlaN
Giga Sage
Giga Sage

Have you ever had the need to retrieve the previous value in the same manner that you do when using the previous object in a Business rule?

There is actually a way to accomplish this.

Since ServiceNow stores most changes in the sys_audit table you can go there to get all previous values if needed.
A fair warning though, the sys_audit table is huge, so don't go down this path if not absolutely necessary.

Now to the solution;
Create a Subflow that takes input parameters on which table, field name, record sysid, and created by.
The subflow itself will be simple, it does a look up on the audit table, using supplied input parameters to get the result, and returns the "oldvalue" value.

Then call on that subflow from whatever Flow that uses the trigger "Record updated"

Example images below.

find_real_file.png

 

find_real_file.png

 

 

find_real_file.png

Comments
pbusch
Tera Expert

This is a bad idea. Having logic like this running will cause global platform performance degradation.

 

Instead, design an Event to grab previous value of the field you care about when the trigger conditions occur.

Then allow the previous value to be passed into the Flow.  Same result, waay less compute.

Version history
Last update:
‎12-15-2021 06:36 AM
Updated by: