Creating a linked field with Scriptin

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 = {
linkedTableId: newFamily.id,
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 …

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
}

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

Sheesh

1 Like