Hi @Brian_McEuen - on the API docs you can see this for a linked field:
To link to new records in Link, add new linked record IDs to the existing array. Be sure to include all existing linked record IDs that you wish to retain. To unlink records, include the existing array of record IDs, excluding any that you wish to unlink.
So if you pass just the new linked record ID, you’ll be left with just that one. The way around this is to get the existing linked record IDs and add your new ID to this array. You can do this with the “spread” operator. The snippet below is from the internal Airtable scripting block, but the same approach would apply using the external API:
let newForeignRecordIdToLink = 'recXXXXXXXXXXXXXX';
myTable.updateRecordAsync(myRecord, {
'myLinkedRecordField': [
...myRecord.getCellValue('myLinkedRecordField'),
{ id: newForeignRecordIdToLink }
]
})
So, you have the existing array of linked records (myRecord.getCellValue('myLinkedRecordField')
) and the new linked field object ({ id: newForeignRecordIdToLink }
), using the spread operator (...
) to join these together.
More info here:
and nicely illustrated by this example:
let parts = ['shoulders', 'knees'];
let lyrics = ['head', ...parts, 'and', 'toes'];
// ["head", "shoulders", "knees", "and", "toes"]