Creating a linked field with Scriptin

Topic Labels: Scripting extentions
1697 2
Showing results for 
Search instead for 
Did you mean: 
4 - Data Explorer
4 - Data Explorer

I am trying to create a field which links a table to itself:
//Now that the table has been created add the linked field
var newFamily = base.getTable( familyName );
var linkOptions = {
prefersSingleRecordLink: true,
isReversed: false,
await newFamily.createFieldAsync( ‘SpouseLink’, ‘multipleRecordLinks’, linkOptions );

I am getting an error:
j: Can’t create field: invalid field config.
Failed schema validation: prefersSingleRecordLink is not included in the .options schema, isReversed is not included in the .options schema

I am confused because I have include those fields in the schema …

2 Replies 2

Welcome to the Airtable community!

Sometimes the error messages and/or documentation are not up to date. Try taking out both isReversed and prefersSingleRecordLink from the options. The scripting documentation currently says to not include them when creating a field.

    // Note: prefersSingleRecordLink cannot be specified via programmatic field creation
    // and will be false for fields created within an app
5 - Automation Enthusiast
5 - Automation Enthusiast

That worked. Serves me right for looking and beleiving the error message which clearly states it is needed!