Closed Ledoux closed 4 months ago
I can't find any working examples of this functionality even from the REST API, in the mean time I would suggest using lookup tables with one field being the primary field:
linked_field1 = table1.create_field(
'contents',
'multipleRecordLinks',
options={
'linkedTableId': table2.id,
}
)
linked_field2 = table2.create_field(
'accounts',
'multipleRecordLinks',
options={
'linkedTableId': table1.id,
}
)```
Reading the API documentation for multipleRecordLinks, it looks like the only options they support for creating or updating fields are linkedTableId
and viewIdForRecordSelection
. The inverseLinkFieldId
and prefersSingleRecordLink
properties are only available when reading the field metadata.
My understanding of how these fields work is that creating a link field from table1→table2 should automatically create the reciprocal field on table2, which you'd be able to identify by looking at the inverseLinkFieldId
property. For example:
>>> created_field = table1.create_field('link', 'multipleRecordLinks', options={'linkedTableId': table2.schema().id})
>>> created_field
MultipleRecordLinksFieldSchema(type='multipleRecordLinks', options=MultipleRecordLinksFieldOptions(is_reversed=False, linked_table_id='tbl...', prefers_single_record_link=False, inverse_link_field_id='fldVIhHyCq5yUbWDb', view_id_for_record_selection=None), id='fld9GFYJfZo8hk1UG', name='link', description=None)
>>> inverse = next(
... field for field in table2.schema(force=True)
... if field.type == "multipleRecordLinks"
... and field.options.inverse_link_field_id = created_field.id
... )
>>> inverse
MultipleRecordLinksFieldSchema(type='multipleRecordLinks', options=MultipleRecordLinksFieldOptions(is_reversed=False, linked_table_id='tbl...', prefers_single_record_link=False, inverse_link_field_id='fld9GFYJfZo8hk1UG', view_id_for_record_selection=None), id='fldVIhHyCq5yUbWDb', name='One', description=None)
I'm going to close this issue since it's not a bug with the pyairtable library. I suggest asking on the Airtable Community Forums if you have follow-up questions or feature requests.
Hi I want to create a link content.account from a 'contents' table towards the associated account (via the content.accountId field).
When I try to create the link and the reverse link :
I cannot, I have such issues :
I tried a bit to add all the permutation possibles with isReversed, and inverseLinkFieldId but I m stuck,it would be cooll to have a better understanding of this api please, thanks a lot:)
Best,