Previous Value of Field On Update

Is it possible to get the previous value of a field to compare to when you have an automation trigger because of an update?

I am thinking the only way to do this is to hold the old value in a hidden field and then update the hidden field after you take care of whatever you needed to take care of.

I think the only issue is a person can make multiple updates to a field before you ever finish the automation so your previous value will be out of date if an update occurs before your first script finishes.

Yep - you’re referring to a multi-pass update process where certain values become dependencies of values that may have changed in the process. This is not possible with Formula fields because an updated formula value destroys the previous value. As such, it must be done with script.

One approach is to simply perform the entire logical process in script by loading the data into an array and use that to perform the business logic. As values need to change, refer to the array version as you build an updated (new array) version of the data. Then replace the data table with the updated array.

1 Like

So people can’t update the table they have to do it within the app? I don’t think that will work.

To be clear I need to know what the value of a field was before the “On Update” automation began running so I know how to handle the update in a script. I just wasn’t sure if there was a way to access the value of a field before it was updated when the on update script runs.

I was thinking that I could store the value of a field in another hidden field and then update that value after I handle the script, however I thought it might not work because a field can be updated multiple times before the first automation ever finishes.

1 Like

Yep - clear requirements and objectives make it easier to advise. :wink:

Is the script that’s triggered by On Update working on one record update or a collection of record updates?

And, are you aware that script actions are not instant (as most devs would expect)? I believe they can occur many minutes after the update actually occurs.

It runs when a field in one of my tables is updated.

I am aware it takes time for an automation to finish. That is what I am trying to point out is that my work around of storing the old value in a hidden field probably won’t work because of that issue. That is why I was hoping that there was some way to access the previous value before the on update ran.

It’s not so much the time that it takes to finish; such a process is likely milliseconds - far quicker than you might imagine. The issue is the timing of it - you really can’t be certain when it will run, but when it does, it will be so quick that no [concurrent] user edits are likely to impact the outcomes.

I don’t think this is an issue at all.

I think the latest historical value saved to an adjacent field will work fine and the cost of trying and testing this hypothesis is near zero.

1 Like