Previous Value of Field On Update

Topic Labels: Automations
3595 6
Showing results for 
Search instead for 
Did you mean: 
6 - Interface Innovator
6 - Interface Innovator

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.

6 Replies 6

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.

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.

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

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.

5 - Automation Enthusiast
5 - Automation Enthusiast

In case there are many quick updates by users, most likely you're interested only in the last (final) update. In that case, you can wait for it and take action only then. Here's a sample code that does that:



    // pass the last modified value of the field as input param to the script
    let last_modified_1 = new Date(inputVars.last_modified_fieldX).getTime();

    while (new Date().getTime() < last_modified_1 + 5000) {
        // do nothing, wait for the updates to settle down (5 sec)

    let table = base.getTable('My Table');
    let rec = await table.selectRecordAsync(rec_id);

    let last_modified_2 = new Date(rec.getCellValue('last_modified_fieldX')).getTime();

    if (last_modified_1 != last_modified_2) {
        console.log("New updates found in the last 5 sec... skipping processing.");

    // process the update, do your thing, use freshly obtained rec for calculations
    // total processing time (including the update of the hidden field in the end)
    // should not surpass 5 sec (otherwise increase the waiting time above)


(note that this code needs to run within a function, due to the "return" statement I'm using for a quick exit)