Upcoming database upgrades. Airtable functionality will be reduced for ~15 minutes at 06:00 UTC on Feb. 4 / 10:00 pm PT on Feb. 3. Learn more here

Two updates in a row

Topic Labels: Scripting extentions
243 1
Showing results for 
Search instead for 
Did you mean: 

Hello guys,
I have a field that tracks the latest payment for a user based on a checkbox.
So basically every time i have a new payment, i’d like to ckeck the checkbox “payment” (if unchecked before). Otherwise, i’d like to uncheck then check it.
But the following code doesn’t do any update when the checkbox was already checked.
How can i make sure these two lines get executed ?

let record = queryResult.getRecord(recordId[0]);
//Uncheck the box if it was checked
                await table.updateRecordAsync(recordId[0], {
                "Payment": false
//Now recheck the box (or simply check it if it wasn't)
await table.updateRecordAsync(recordId[0], {
        "Payment": true

Thanks for the help !

1 Reply 1

Try simplifying your code down:

let record = queryResult.getRecord(recordId[0]);
await table.updateRecordAsync(record, {
   "Payment": record.getCellValue("Payment") ? false : true