Hello,
When I run the script below as an automation, I get an error:
Script exceeded execution time limit of 30 seconds
Here is the code:
let table = base.getTable("WPS-EVRI");
let result = await table.selectRecordsAsync();
let sums = {};
for (let record of result.records) {
let customerAndWeek = record.getCellValue("Customer & Week");
if (!sums[customerAndWeek]) {
sums[customerAndWeek] = 0;
}
sums[customerAndWeek] += record.getCellValue("DA Amount");
}
let updated = {};
for (let record of result.records) {
let customerAndWeek = record.getCellValue("Customer & Week");
if (!updated[customerAndWeek]) {
let matchingRecords = result.records.filter(r => r.getCellValue("Customer & Week") === customerAndWeek);
for (let matchingRecord of matchingRecords) {
await table.updateRecordAsync(matchingRecord, {
"Total This Week (DA)": sums[customerAndWeek]
});
}
updated[customerAndWeek] = true;
}
}
Is there a way to edit this script so it shortens the timeframe of running?
Any help is greatly appreciated! 🙂