Hi there,
I adapted the below script by @Justin_Barrett. Everything was working great until I added a few hundred new records to the ‘TaskLog’ table.
The script now throws this error:
Exceeded quota of 15 mutations per second at main on line 20:
let result = await table.selectRecordsAsync()
In addition, the run time is now 23.8/30s - also an error for my purposes - as any run time that goes over say 6-seconds will make the script unusable.
Can anyone tell me exactly how to edit the script to include batch processing or another solution that will solve the two errors at hand?
Ideally, the script should be able to quickly search through thousands of records in the TaskLog table in order to mark the ones that match the Account ID from the first step of the automation (inputConfig.AccountID)
Here is the script:
// Remove all existing markers (ie make all Task Log records 'current' value null)
let TaskLogTbl = base.getTable("TaskLog");
let TaskLogRcds = await TaskLogTbl.selectRecordsAsync();
for (let record of TaskLogRcds.records) {
// Change Current field value for all records to Null
TaskLogTbl.updateRecordAsync(record, {
"Current": null
})
}
let table = base.getTable("TaskLog");
let field = table.getField("Account");
let inputConfig = input.config();
let inputValue = inputConfig.AccountID;
// Load all of the records in the table
let result = await table.selectRecordsAsync();
// Find every record we need to update
let updates = s];
for (let record of result.records) {
let originalValue = record.getCellValue("Account");
let recordValue = record.getCellValue("Account");
if (recordValue == inputValue && originalValue != inputValue) {
updates.push({
id: record.id,
fields: {
"Current"]: null,
}
});
} else if (originalValue && originalValue != inputValue) {
updates.push({
id: record.id,
fields: {
"Current"]: "1",
}
});
}
}
// Update records - Only up to 50 updates are allowed at one time, so do it in batches
while (updates.length > 0) {
await table.updateRecordsAsync(updates.slice(0, 50));
updates = updates.slice(50);
}