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”).
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.
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.
For each table name, use search() to get a row. (If the table has no rows, then add one, temporarily.) From the row, get its id. Extract the first number from the id. Now you have a listing of table names and ids, and can look it up.