I’m trying to create a script in Airtable linked to a button. The process is as follows:
- Button within Airtable pressed
- If the checkbox field ‘switch’ is false, then turn it to true
- Wait for 2 seconds, reset the field to false
This is the script I’ve written using the setTimeout() function:
let table = base.getTable("EXM"); //The name of the table you're in here
let record = await input.recordAsync('Pick a record', table);
if (record) {
if (record.getCellValue("switch")===false) {
table.updateRecordAsync(record, {'switch': true});
output.text('checkbox ticked');
}
const myTimeout = setTimeout(timeDelay, 2000);
function timeDelay()
table.updateRecordAsync(record, {'switch': false});
output.text('2 second interval');
}
When I write the code I get an error that says “cannot find name setTimeout”. As a solution, it suggests “add missing function declaration ‘setTimeout’”
How do I declare this function so it can function with my code?
