Get app_table table object by table ID

Good morning!

I am managing data using from the CSV builtin table export. For linked rows the export gives “#ROW[123,456]” or “#ROWS[[123, 789]]” where the first element in the linked row corresponds to the table ID and the second to the row ID in that table.

I would like to be able to access the corresponding table via app_tables.get_table_by_id(“123”).

Thanks,

Ty

3 Likes

I’ve noticed the same thing. As I understand it, however, this particular representation of row ids is subject to change without notice, so I’m reluctant to depend on it in any way.

I’d like to suggest a slightly different idea, one that does not depend on the internal structure of a row id. E.g.,

app_tables.get_table_by_row_id(s)

where s is any string containing a row id. In short, let Anvil pick it apart for you. That way, when the representation changes, it will be Anvil’s responsibility to keep this function working, not yours.

Would that work for you?

4 Likes

I agree with @p.colbert, but in the mean time you can see the row id with row.get_id() and (if I remember correctly the row id format) you can use app_tables.table_name.get_by_id('[123,456]') (no space after the comma) to get the row.

I have the row and row ID, I need the table_name from the row ID.

1 Like