I want a select control/column to be able select from multiple tables. That part is easy
Table A.ListCombine(Table B)
and values from both tables are shown.
The issue is when I want to get a value from the selected row. In a select control, autocomplete only lets me choose columns from the currently selected value, and in a select column nothing. Even if “trick” autocomplete to offer everything, by selecting different values from all tables between formula edits, in the end the formula still reports an error.
This is just a sample, but it illustrates the idea:
SwitchIf(
SelectedRow.IsBlank(), "Nothing selected",
SelectedRow.IsFromTable(Table A), SelectedRow.DataA,
SelectedRow.IsFromTable(Table B), SelectedRow.DataB
)
In short, my question is is there a nice way to “cast” a row so it’s data can be accessed directly?
It seems to me that there is a missing complementary function to IsFromTable
, something like Cast(SelectedRow, Table A)
, or IsFromTable
should return the already properly typed row or “null” (or whatever is considered an empty value in Coda) if the row is not from the passed table.
Solutions I can currently think of:
- Convert the row to json with “_Merge” and parse until I find the value. Very brittle, and using a hidden formula.
- After checking to which table the row belongs to, perform a table search to get the same row but properly typed. More code, potentially slow with a lot of data.
SwitchIf(
SelectedRow.IsBlank(), "Nothing selected",
SelectedRow.IsFromTable(Table A), Table A.Filter(SelectedRow).First().DataA,
SelectedRow.IsFromTable(Table B), Table B.Filter(SelectedRow).First().DataB
)
- Anything else?