Hi!
I’m working on a script to batch update linked fields and it seems to work for the most part but eventually throws this error:
I have checked for duplicates in the tables I’m working with but there are none. Any ideas what might be causing this? Here’s the script for reference:
//Define the company table and query
let cmpTbl = base.getTable("Companies");
let cmpQuery = await cmpTbl.selectRecordsAsync();
//Define people table and query
let pplTbl = base.getTable("People");
let pplQuery = await pplTbl.selectRecordsAsync();
let updates = [];
// Search for matching records and batch update
for (let allPeople of pplQuery.records){
let cmp = allPeople.getCellValue("Company")
for (let allCompanies of cmpQuery.records){
if (cmp === allCompanies.getCellValueAsString("Company")) {
let cmpID = allCompanies.id
updates.push({
"id": allPeople.id,
fields: {"Companies 2.0": [{id: cmpID}]}
});
}
}
}
console.log(updates)
while (updates.length > 0) {
await pplTbl.updateRecordsAsync(updates.slice(0, 50));
updates = updates.slice(50);
};