Simple Trick: Keep using row data in same action *after* you already deleted the row

Hi there my friends. I am not going to deeply discuss the scenario where this applies, its complex.
So I am just placing here this solution in case anyone else needs it:

Problem:
Say you need to execute several actions for a row, where one of them is delete that row, and after deletion, you need to trigger and update action in a related row on another table.

There is a way, using FormulaMap to store the data

Solution:

RunActions(
    ...
    "Several actions
    ...
    FormulaMap(
        thisRow.relatedRow,            "Here you store your value: the related row you will use later
        DeleteRows(thisRow),           "Then, you delete your row
        CurrentValue.UpdateData        "Now, you update data in your related row, where you needed current row gone for correct calculation
      )
)

Why

Why would I manually want propagate changes through my model instead of directly relate changing fields to each other with formulas?

Because those related fields will severely impact in performance if your document is complex. By manually changing only data you want, when an user executes those changes, you significantly improve performance.
Disclaimer: Those are my assumptions, I can’t be sure of this statements.

Be wary keeping good UX in this manner will require to create lots of forms by using more auxiliary tables.

--------------------------Update april first, 2022------------------------

As @Einar_Boson suggested in replies, this trick isn’t necessary anymore, since WithName formula can cope with this kind of need.

4 Likes

Huh, this is smart. Using CurrentValue as an arbitrary variable storage by passing that variable as a FormulaMap source. I don’t know where I’d need this yet (normally I’d just swap the update and delete, or use IsFromTable() to filter out a deleted reference) but a nice trick to have upon one’s sleeve nonetheless. I haven’t thought of this myself.

Thanks for sharing.

I need to play around with this idea more. E.g. here’s one way to push multiple variables in nested formula maps:

image

Now I need some useful application of this.

Maybe it’s also possible to achieve the nested CurrentValue calculation using this trick. Previously the only viable way I found (with live formulas, not actions) is this:

And with actions I almost exclusively use this trick: Tutorial: Iterator tables (CurrentValue workaround). It’s universal enough to be considered as a to-go solution, a reusable design pattern (if you’re a software engineer, I mean something like GoF patterns)

Ended up here with google for some reason.

Check out WithName in Coda | Formula library for a clearer pattern:

WithName(thisRow.relatedRow, theRowNeeded,
   RunActions(
        DeleteRows(thisRow),
        theRowNeeded.UpdateData 
    )
)

1 Like

Yeah, thanks for the addition @Einar_Boson . When I first published this, WithName didnt existed yet…

I update with your suggestion my thread

1 Like