Jun 27, 2023 09:16 AM
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'}}
Solved! Go to Solution.
Jun 27, 2023 11:21 PM
Hi,
- You should set only LinkedTableID option.
- You should choose other field type for primary
For example, that works
Jun 27, 2023 11:21 PM
Hi,
- You should set only LinkedTableID option.
- You should choose other field type for primary
For example, that works
Jun 28, 2023 07:28 AM
Thank you so much, Alexy! This worked. I very much appreciate the time you too to help me out!
Nov 10, 2024 02:18 AM
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?
Nov 11, 2024 01:17 PM
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:
Nov 12, 2024 11:36 AM
Thanks for the explanation!