Help

Automated script to sum column is timing out after 30 seconds error.

Topic Labels: Automations
1011 2
cancel
Showing results for 
Search instead for 
Did you mean: 
DeepSea
4 - Data Explorer
4 - Data Explorer
Hello,

I have a script running automatically when the USD balance of my expense sheet is changed. It updates the balance column to track expenses.

 

 

 

// 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?

2 Replies 2
Airbid
6 - Interface Innovator
6 - Interface Innovator

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

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.