Adding multiple rows of data through a button via formula map

I have a feeling that

Monitor Name = CurrentValue

within the AddOrModifyRows is not behaving as you expect, since CurrentValue resolves not to a row in Monitors Template table but to the currently evaluated row within the Client + Template table (as evident by color coding, although sometimes that’s wrong too), hence the check is always false.

One of the reasons I don’t like AddOrModifyRows.

I’d suggest rewrite the formula with explicit conditional instead:

[Monitors Template].Filter(...).FormulaMap(
  If(
    [Client + Template].Filter(...).Count() = 0,
    [Client + Template].AddRow(...),
    _Noop()
  )
)

That’s how I’d usually do it. No unnecessary modification too (and no spamming the activity log / touching the Modified() timestamps etc).


P.S. Actually no, that won’t work, since you cannot access outer CurrentValue from the inner Filter either. You’ll most likely need to implement this trick:


P.P.S. Might be worth looking into the possibility of replacing FormulaMap with individual buttons. on the rows from Monitors Template, then filtering and clicking those buttons instead. This eliminates the need of one level of CurrentValue because in those buttons you can read directly from thisRow, and you won’t need the trick then.

Hi @erik,
take into consideration what @Paul_Danyliuk suggested you.

However, I guess that one point in your formula is that you check Monitor Name = @CurrentValue (being @CurrentValue the current row) but then you set value of the target column with its column (Monitor Name).

Try to change the last Monitor Name with CurrentValue and it should work.

Let us know!

This is my favourite way.
Also much easier to test/debug

Well I doubt that; I am almost completely sure that CurrentValue is always overridden in AddOrModifyRows to the current row in this table.

Have a look, @Paul_Danyliuk:

Sorry, not intuitive to me at all. I’m clicking the buttons but the rows added seem off (they all list both customers etc).

Did I mention before that I’m not that good with abstractions like apples and potatoes? I cannot deduce what the actual requirement is behind that.

P.S. nvm I think I know what they are trying to do.

That was the example shared by @erik hat I used to implement the formula.
I guess you have to read for the beginning.
Long story short: after setting up Templates with items per each Platform, in the Customer Database you assign all the items to each customer in the Client + Template table.

I struggled with names… but this is it :grimacing:

So, my point ids that this formula is incorrect because it should use CurrentValue instead of Monitor Name.
This way it works.

Redefining it a single row level-button is a suggestion that I’d consider (is what I usually do), anyway.

Okay, I think I did it:

I ended up implementing the trick above because other solutions seemed less intuitive. A template-row-level button wouldn’t work because that button wouldn’t know which client you’re adding the row for (unless you assigned that client onto a Platform record, which would’ve been a spaghetti solution)

image

It copies data from the template into C+T rows, but if you’re fine with lookup formulas you can clean those copying up.


I know it may be a lot to take in for someone who’s not so experienced with Coda. Unfortunately, loss of outer CurrentValue is a known problem and there’s no beginner-friendly workaround for that. The most bulletproof and logical solution is the one I implemented; in some cases it may be avoided but not yours.

1 Like

Hey guys,

Thank you for all the help. There is a bunch to take in here, so I’m going to go over it a couple times and see if I can wrap my head around it. I’ll let you know if I have any questions. All the help is greatly appreciated!

2 Likes

Actually just thought of one solution that wouldn’t require a temp column. The trick is to pre-filter the template rows and only FormulaMap over those that were not added yet. Now, CurrentValue is overridden in a filter within a filter, but in this case that check could be replaced with Contains():

1 Like

Hey Guys,

I’m going through this testing out some of the options and making changes. I’m running into an issue where in the test doc you perform a lookup on “Template Rows” table, which gives you the Name (i.e “pink”, “baby potatoes”) within the platform

For some reason, when I copy this onto my doc (changing the table names of course), it only gives me the platform name here instead of “Insert Name Here”

image

Any idea why this could be happening?

Just bumping the thread =)

Hi @erik,
you did right in getting proper attention :slight_smile:
Unfortunately I didn’t actually understand your issue…

Isn’t perhaps just a “Display Column” problem?

2 Likes

I had no idea what you meant by “Display Column” at first, but that pointed me in the right direction to what I needed and I think I was able to figure it out. I just tested on one customer and it does not appear to be adding duplicates now and it’s displaying what it should be. I’ll continue to test to make sure, but it looks good so far. Again, I want to thank you guys for all the help and I’ll keep you posted =)

2 Likes

And keep on asking (and bumping) whenever needed! :grimacing:

Sharp :eyes: for the details :trophy:

Ok, so this works as intended but with a catch. Apparently the doc is too large and I can’t use the button with automation to run against all clients at once because there is a cap on automation sizes. Need to break it out so the button only runs chunks of 5 clients at a time.

Any thoughts on this? I’m assuming I need to find something that gets the first five clients, runs the updates, the moves to the next five? I’m looking through the documentation to see what I can find. Any help is appreciated.

:grinning: Bumping the post.

Sorry for the late reply. Here’s how I deal with docs that become too large because of button columns: