Help

Upcoming database upgrades. to improve our reliability at 03:30 UTC on Feb. 25 / 7:30pm PT on Feb. 24. Some users may briefly experience slow load times or error messages. Learn more here

Create Multiple Linked Records

Topic Labels: Scripting extentions
Solved
Jump to Solution
1207 2
cancel
Showing results for 
Search instead for 
Did you mean: 

Hi Everyone!

Thanks for you time beforehand and apologies if this case was already resolved in another topic (altough I couldn’t find any similar). I am pretty new to airtable scripting and I hit a roadblock in one of my codes.

I need to iterate and create multiple linked records into a table, but my code is throwing me the following error “j: Can’t create records: invalid cell value for field ‘Property’.
Cell value has invalid format: .0.0 must be an object.
Linked records field value must be an array of objects with property ‘id’ corresponding to linked record id.”

I assume this is because I have to put some sort of id in the createRecordAsync function, but I am not sure how the syntax for that should be.

Full code:

let importTable = base.getTable('Master List');
let importView = importTable.getView('Active');
let importQuery = await importTable.selectRecordsAsync();
let newTable = base.getTable('New Table');

for (let record of importQuery.records) {
    let recordName = record.getCellValue('Name');
    await newTable.createRecordAsync({
        "Linked Field": recordName})
    output.text(`New record for ${recordName} created!`);}
1 Solution

Accepted Solutions

Welcome to the Airtable community!

When you create a new record the field values need to be in the proper write format. You can see the format for a linked record field in the documentation.

You probably want something like

    "Linked Field": [{id: record.id}]
})

See Solution in Thread

2 Replies 2

Welcome to the Airtable community!

When you create a new record the field values need to be in the proper write format. You can see the format for a linked record field in the documentation.

You probably want something like

    "Linked Field": [{id: record.id}]
})

That was it, thanks!!