Help

updateRecordAsync - some are updating, others are not

Topic Labels: Scripting extentions
Solved
Jump to Solution
1897 1
cancel
Showing results for 
Search instead for 
Did you mean: 
ATG
6 - Interface Innovator
6 - Interface Innovator

I have a scripting block that, for each record R in a given table, pulls a bunch of data from a different table, calculates a number N, and updates a field F for that R.

The problem is some records are updated and others are not.

I know that records are being pulled correctly as I print N for every R and it all calculates correctly. I know that the update code works as some records will update.

One interesting thing to note: the updated R I think are all old and the non-updating ones were recently added. I thought this might have been a Free/Plus/Pro account issue as only Pro supports Apps and maybe older records were grandfathered but I have paid for Pro and still no go. Is this a permissions issue?

By the way, are apps the same as scripting blocks or different?

Code in question below:
let table = base.getTable(BaseSpecificNames.cashFlowTable);
let view = table.getView(BaseSpecificNames.sortedView);
let query = await view.selectRecordsAsync();
let filtered = query.records;
let dtable = base.getTable(BaseSpecificNames.dealsTable);
let dquery = await dtable.selectRecordsAsync();

for(let record of dquery.records)

{
let dealnum = record.getCellValue(BaseSpecificNames.dealsIDField);
let dealname = record.getCellValue(BaseSpecificNames.dealNameField);
filtered = query.records.filter(record => {
return (record.getCellValue(BaseSpecificNames.dealID) == dealnum);
});

let IRR = calcIRR(dealnum);
output.text(dealnum + ":\t" + dealname + ":\t" + IRR);

//THIS IS THE UPDATE IN QUESTION
dtable.updateRecordAsync(record, {“IRR”: IRR});

}

1 Solution

Accepted Solutions
ATG
6 - Interface Innovator
6 - Interface Innovator

Fixed it.

The issue was somehow due to the async nature of updates. Needed to add an ‘await’ before the update. No point trying to debug why only old records updated and new ones didn’t…although it really really confused me.

await dtable.updateRecordAsync(record, {“IRR”: IRR});

See Solution in Thread

1 Reply 1
ATG
6 - Interface Innovator
6 - Interface Innovator

Fixed it.

The issue was somehow due to the async nature of updates. Needed to add an ‘await’ before the update. No point trying to debug why only old records updated and new ones didn’t…although it really really confused me.

await dtable.updateRecordAsync(record, {“IRR”: IRR});