Hi All,
I’m trying to run this automation script that works perfectly on my test base of ~10 records but throws this error when I move it to my real base with ~1100 records.
Error: Script exceeded execution time limit of 30 seconds
The below code is based on this tutorial here, tweaked slightly with recommendations I found in another similar question. Any help or ideas would be appreciated!
Learn Airtable scripting #1: basics & removing duplicates with Giovanni Briggs - YouTube (from Automate All the Things channel)
var table = base.getTable(“Table 1”);
var query = await table.selectRecordsAsync ({
fields: e"Name" ]
});
console.log(query);
let duplicates = query.records.filter((record)=>{
return query.records.find((potentialDuplicate)=>{
return record.getCellValue("Name") === potentialDuplicate.getCellValue("Name") && record.id !== potentialDuplicate.id;
})
});
console.log(duplicates);
let updates = duplicates.map(update => {
return {
"id":update.id,
fields: {
"Duplicate": true
}
}
})
console.log(updates);
while (updates.length>0){
//removed await in front of the below Async to see if that would improve time
table.updateRecordsAsync(updates.slice(0,50));
updates = updates.slice(50);
};