Can the 'execute' property of pack.AddFormula addRow()?

Before packs:
In my table, I have a button that pushes other buttons in the same row (runActions()). Each child button in the row has some complicated formulas inside that will basically AddRow() using data from thisRow. Moreover, each child button’s AddRow() formulas are nearly identical, so if I modify one button, I then have to tediously modify the others. (I attempted to consolidate them into 1 button using withName(), but it became even more complicated.)

So now, I am attempting to consolidate all of this logic into one super button, powered by a Coda Pack formula.

After packs:
In my pack formula, I set isAction: true, and Coda allows me to use the custom formula in my parent button! In the button formula editor, I can associate columns with formula parameters. However, inside the execute property of my pack.AddFormula, I cannot find a way to use AddRow() based on the parameter data.

Although, asking a formula to addRow() would probably require it to know the structure of the document. Maybe this could be achieved by prompting the user to create or associate the required tables/columns, but this sounds messy.

Could your pack formula instead return an object (a mapping of columns to values adhering to the declared formula schema) that is passed to AddRow() which can create from this mapping a row in the table?


Hey @loucadufault that’s a clever idea! Thanks for pointing me in the right direction. I am finding other useful posts now that I have these keywords. I’ll try and let you know – thanks!

1 Like

@loucadufault has the right idea. Just to clarify, the answer to your original question is no, Pack formulas cannot add rows directly. All Pack formulas can only take in data and return data. However these can be chained together with other native formulas, like AddRow(), to modify the document.


This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.