Hello everyone,
I’m trying to create from a row button in table A, a new row in table B for each row in table C
I’m managing to do that with the formula:
FormulaMap(C, AddRow(B))
The thing is I want to use data from table A and C for new rows in B, and I can’t figure out to do the following
Use the “Name” of each row in table C when creating B Row
This is my latest result: All the C rows’ names are used instead of one
Formula : FormulaMap(C, AddRow(B,Content,thisRow.Content,C,C.Name))
If you could give me some help, it would be amazing !
Thanks
Matthias
3 Likes
Hey @Matthias_Riverti1,
I got your desired result with this Formula:
FormulaMap(C, AddRow(B,Content,thisRow.Content,C,CurrentValue.ToText()))
I think ‘Currentvalue’ stores the current object you are going through with FormulaMap.
You can also remove the “totext()” to get it as a connected row and not the text only.
EDIT: This is a perfect case of ‘how to ask for help’ your example, current step and visualization makes it very clear what you want. Maybe others in need can take it as an inspiration.
9 Likes
I just applied Daniel’s solution for a similar situation in my own Doc. I can confirm that it does work.
However, it seems like CurrentValue is being misidentified and color coded as being from the wrong table. Table B, in this case. Because of this, I haven’t been able to select a different column from the CurrentValue row. I can only use the display column.
In this example, the Snacks can’t be copied to B:
1 Like
That is absolutely right. The problem: (as far as I know) you can not address a column of a linked row from a different table. (The same applies, when you have a table lookup and you want to address another column of that.)
I usually workaround it with filtering, but this can be dangerous if e.g. your values are not unique:
1 Like
This CurrentValue
misidentification problem has been going for ages, always happens when you nest two formulas that use it (in this case FormulaMap
and AddRow
).
Another workaround is to Simulate a For Loop so you can access the Nth
value of each of C 2
's columns. This way you also avoid the possible problem of duplicates that @Daniel_Stieber mentioned.
See it working:
5 Likes
Thanks a lot for the solutions !!
I tried @Daniel_Stieber one and it works great.
I do agree that the color bug is misleading. But I guess we are pushing the tool to the limit with that kind of usage.
I didn’t try your option @Dalmo_Mendonca, but it seems perfect for even more complicated use cases
1 Like
Just want to say this is a clear bug - the documentation for FormulaMap
says that currentValue
should reference the row iterated from the source table.
Would be nice to get it fixed, as far as I can tell it’s not working at the moment.
1 Like
One potential fix is to show multiple currentValue
references in the popup window as the user begins typing currentValue
, similar to how typing a column name will show multiple color-coded column names that belong to different tables in a formula (although this took me a while to figure out but once known it’s quite easy).
There are design issues here though, since the functions themselves are not color-coded for example, and the same function could be nested, so function name alone also isn’t enough.
Perhaps the owning function call could be highlighted when the user selects with up/down key.
Hi @Allen_Ormond while the ability to use another column from the Table C is a major issue, there is a workaround. While setting the value for a column in Addrow formula, you can filter the Table C and then access the required column.
C.filter(Name=currentvalue.totext()).snack.
I have used this approach in one of my quite complex Coda doc.
1 Like