I've been trying to update a multipleCollaborator field without overwriting. Specifically I have a lookup field with user IDs and I'm trying to copy the same IDs (hence collaborators) to another (empty) collaborator field.
This should be relatively simple and yet i get a "TypeError: record.getCellValue is not a function or its return value is not iterable"
// This script downloads all the Auto-Requester's Collaborator IDs and re-prints them in Requester
const config = input.config()
const recordAT = config.recordAT
const autorequester = config.autorequester
const requester = config.requester
const table = base.getTable('Deliverables')
console.log(autorequester)
for (var arID of autorequester) {
let queryResult = await table.getView('All All').selectRecordsAsync({fields: ["Requester"]});
let record = queryResult.records.find(r => recordAT)
console.log(record.getCellValue("Requester"))
await table.updateRecordAsync(recordAT,
{
'Requester' : [
...record.getCellValue("Requester"),
{id: arID}
]
}
)
}
Airtable documentation says:
NOTE: When updating array-type fields (attachment, linked record, multiple select, multiple collaborators), you must set a new array of items. Whatever value you set will override the previous value. If you wish to append to the existing values in the cell, you can spread the current cell's items. For example:
updateRecordAsync(recordToUpdate, {
'Linked record field': [
...recordToUpdate.getCellValue('Linked record field'),
{id: 'recABC123xyz'}
]
});
Any help much appreciated!!