Sep 24, 2023 04:04 AM
// change these names to pick a view:
let table = base.getTable('Tangle Treasury Expenses');
let view = table.getView('Grid view');
let result = await view.selectRecordsAsync();
let runningTotal = 0;
for (let record of result.records) {
// change the field names here to adapt this script to your base
runningTotal += record.getCellValue('USD Formula');
await table.updateRecordAsync(record, {
'USD Balance': runningTotal,
});
}
It keeps timing out at 30 seconds. Randomly it successfully completes at 28 seconds but rare.
Any options to fix this?
Sep 25, 2023 08:14 AM
your ‘Grid View’ view only needs to have the USD column make sure that there are no other columns visible in that view otherwise, the data in those columns will be queried as well, so if there is a lot of data, the script is going to take a lot longer to run
Sep 25, 2023 10:30 AM
You can also speed up execution by moving table.updateRecordAsync() outside of the loop. Create an array of the changes and then apply the changes in a batch with table.updateRecordsAsync(), which can handle 50 updates in a single call.