Help

Re: Creating a table with multipleRecordLinks Field with Rest API

Solved
Jump to Solution
1259 1
cancel
Showing results for 
Search instead for 
Did you mean: 
EricJ
5 - Automation Enthusiast
5 - Automation Enthusiast

Hello Airtable people!

I am trying to use the Rest API through a python script to create a subcategories table with a multipleRecordLinks field that links to a category table. I am having the toughest time trying to create this field and decipher the error messages I am getting. I am hoping someone on this community can help me.

My first attempt looked something like this:
{
"description": "A list of all of the subcategories",
"fields": [
{
"name": "Category",
"options": {
"linkedTableId": "tblPyvCqwd50kh7P2",
"inverseLinkFieldId": "flduKctYyZ1ckgVxR",
"isReversed": false,
"prefersSingleRecordLink" : true
},
"type": "multipleRecordLinks"
},
{
"description": "Name of the subcategory",
"name": "Subcategory Name",
"type": "singleLineText"
},
{
"name": "Display Color",
"type": "singleLineText"
}
],
"name": "SubCategories"
}

And I get this error message saying that options that I've included are not included:
{'error': {'message': 'Invalid options for SubCategories.Category: Failed '
'schema validation: inverseLinkFieldId is not included '
'in the Category.options schema, isReversed is not '
'included in the Category.options schema, '
'prefersSingleRecordLink is not included in the '
'Category.options schema',
'type': 'INVALID_FIELD_TYPE_OPTIONS_FOR_CREATE'}}


I read this post (https://community.airtable.com/t5/development-apis/creating-a-linked-field-with-scriptin/td-p/98017) and tried to take out isReversed and prefersSingleRecordLink as suggested:

{
"description": "A list of all of the subcategories",
"fields": [
{
"name": "Category",
"options": {
"linkedTableId": "tblx441joiqxYei9L",
"inverseLinkFieldId": "fldlrQUYUD5zG3M0r"
},
"type": "multipleRecordLinks"
},
{
"description": "Name of the subcategory",
"name": "Subcategory Name",
"type": "singleLineText"
},
{
"name": "Display Color",
"type": "singleLineText"
}
],
"name": "SubCategories"
}

Here is the error I got, looks very similar to prior message. I am not sure what the difference between Category.0.options and Category.1.options are, but noted the error mentioned both.
{'error': {'message': 'Invalid options for SubCategories.Category: Failed '
'schema validation: Category.0.options.isReversed is '
'missing, Category.0.options.prefersSingleRecordLink is '
'missing, inverseLinkFieldId is not included in the '
'Category.1.options schema',
'type': 'INVALID_FIELD_TYPE_OPTIONS_FOR_CREATE'}}


Tried just taking out prefersSingleRecordLink because I found docs that said this can't be used when scripting tables.
{
"description": "A list of all of the subcategories",
"fields": [
{
"name": "Category",
"options": {
"linkedTableId": "tbl8DJjJBtgKtygF8",
"inverseLinkFieldId": "fldLtd9Gj4XjUQ049",
"isReversed": false
},
"type": "multipleRecordLinks"
},
{
"description": "Name of the subcategory",
"name": "Subcategory Name",
"type": "singleLineText"
},
{
"name": "Display Color",
"type": "singleLineText"
}
],
"name": "SubCategories"
}
{'error': {'message': 'Invalid options for SubCategories.Category: Failed '
'schema validation: '
'Category.0.options.prefersSingleRecordLink is missing, '
'inverseLinkFieldId is not included in the '
'Category.1.options schema, isReversed is not included '
'in the Category.1.options schema',
'type': 'INVALID_FIELD_TYPE_OPTIONS_FOR_CREATE'}}

 

1 Solution

Accepted Solutions
Alexey_Gusev
13 - Mars
13 - Mars

Hi,
- You should set only LinkedTableID option.
- You should choose other field type for primary

For example, that works

Alexey_Gusev_0-1687933103405.png

Alexey_Gusev_1-1687933278994.png

 

See Solution in Thread

5 Replies 5
Alexey_Gusev
13 - Mars
13 - Mars

Hi,
- You should set only LinkedTableID option.
- You should choose other field type for primary

For example, that works

Alexey_Gusev_0-1687933103405.png

Alexey_Gusev_1-1687933278994.png

 

EricJ
5 - Automation Enthusiast
5 - Automation Enthusiast

Thank you so much, Alexy! This worked. I very much appreciate the time you too to help me out!

Hi Alexey,

I tried this approach. However, it won't link the field to the primary key of the target table. Instead, it reports yet another field ID as the inverseLinkFieldId. In the Airtable UX, I cannot select any of the records of the target table either. How can I achieve that the record link actually points to the primary key of the target table?

Hi.
Linking works in a bit different way.
Each link points to a whole record. The record name is the text shown in link. other field values can be used when you set up lookup/rollup fields. 
When you create linked field to other table, in other table auto-created linked field to a first table, where all  links from first table 'mirrored'. The id of this new field is the inverseLinkFieldId returned to you.
That's a simple example how it works:
Alexey_Gusev_0-1731359636183.png

 

Thanks for the explanation!