Airtable Automation/Script to Delete Record

Hi, I’d like to delete a record when a checkbox is selected. I’ve set up the automation but have zero knowledge of scripts. What is missing here?

let table = base.getTable("Room Reservations");
let inputConfig = input.config();
let recordId = inputConfig['recordId']
await table.deleteRecordAsync(recordId);```

Thanks so much

Welcome to the Airtable community!

Have you set up recordId as the input variable for the script?

Have you setup the trigger for the automation?

1 Like

@kuovonne Thank you!
I set up the input variable and it worked like magic, thanks.

1 Like

hi - i have this and i keep getting an error:

let table = base.getTable(“Vibe Stages”);
let inputConfig = input.config(recordId);
let recordId = inputConfig[‘recordId’]
await table.deleteRecordAsync(recordId);

ReferenceError: Cannot access ‘recordId’ before initialization
at main on line 2

Welcome to the Airtable community!
You have copied the script incorrectly. Look at the second line of the script.
You want …

let table = base.getTable("Vibe Stages");
let inputConfig = input.config();
let recordId = inputConfig['recordId']
await table.deleteRecordAsync(recordId);

Thanks! when i do that i get this error
Screenshot_5

Did you create your input variable?

how do i do that? i thought the record id was the variable

You have to setup the input variable in the left section of the script editor. There is a link in that section to more documentation if you need more help.

that did it! thanks!