Data tables link multiple rows

Not sure what I am doing wrong here :smiley: anyhelp is appreciated.

I have two tables… table A and table B. Table A has a column that links to multiple table B entries. I am trying to create a new row in table A and also a new entry in table b and link them but it doesnt seem to be working.

i.e
tableb = tables.app_tables.tableb.add_row(name=name)
tables.app_tables.tablea(class=class,tablebs=tableb

This works with a single row but doesnt seem to work with a multi row. I get the following error:
anvil.tables.TableError: Column ‘tablebs’ is a liveObjectArray - cannot set it to a Row from ‘tableb’ table

Thank you for your time

Hi Chris,

multiple links are arrays of data objects, so you need to do something like this :

rb = app_tables.tableb.add_row(name="new b")
ra = app_tables.tablea.add_row(name="new a",linktoB=[rb])

note the square brackets around the linked data.

Here is a small app showing it working. Click the button the stop the app and check the data tables’ entries :
https://anvil.works/build#clone:MCRQA67KJ5XSPB7J=XYMKBKXG23BBT6EPCTPWVEFT

3 Likes

Thanks David it was that simple :smiley: superstar thank you

1 Like