May 04, 2021 11:16 AM
I was wondering if it was possible to setup an automation that would auto delete a record with a specific single-select field entry after 30 days or something.
May 04, 2021 12:34 PM
Hi @Jeffrey_Yau - Airtable automations don’t currently have a delete action, but you can do the following:
When a record enters a view => Run a script
The view would be defined as:
The script would take the record from the trigger and delete it - see here for more details:
Jul 29, 2021 04:30 PM
Hi :wave: , this is an old post, but I will leave this solution for other people looking for it.
You can use this code inside the automations in a “Run script” step:
let inputConfig = input.config(); const id = inputConfig.id; const Table = base.getTable(inputConfig.Table); await Table.deleteRecordAsync(id);
You then configure “Table” & “id” as input variables, “Table” is the name of the table of the record, and “id” is the Record ID that regularly will come from a previous step.
This step will delete the record with that record id.
Jun 15, 2022 07:38 AM
You then configure “Table” & “id” as input variables
Hello @SergioCodes , I am trying to use the code you posted above but with little luck. I don’t know how to set up the variables and I get
TypeError: Invalid arguments passed to base.getTable(idOrName): • idOrName should be a string, not undefined
could you elaborate a little?
Jun 15, 2022 05:45 PM
Happy to help, just change this line:
const Table = base.getTable(inputConfig.Table);
const Table = base.getTable("TableName");
Where “TableName” is the name of your table and it should work
Jun 16, 2022 07:20 AM
Jun 21, 2022 04:33 AM
Hey, I am not sure what I am doing incorrect. I have no idea how scripts work.
Can you please help me?
Jun 21, 2022 05:34 AM
You cut off the right side of the screen in your screen shot. What does it say?
Are you getting an error when you run the script? Have you tried retesting the trigger to get a new record ID? If you have already deleted the record, you cannot delete it again.
What is the value of your id? The script won’t work unless it is exactly one Airtable record ID. E.g. it won’t work if there are no IDs in the input variable, and it won’t work if there are multiple record IDs, and it won’t work if the IDs are not Airtable record IDs.
By the way as a matter of styling, it is customary to start variable names with a lower case letter, so
Table would be
table. However, this is not what is causing your issues.
Jun 21, 2022 08:13 AM
Thank you for the response.
My previous step is “Find Record” which will always fine one record alongwith its record id.
It is actually one record id only but I assume, since find record module gets array of the records (whether one record or more than one), it may not be working. I tried putting actual record id, it was working properly.
Any specific solution?
Jun 21, 2022 08:40 AM
No specific solutions. But try
console.log(id) to see what the actual value is. Then also search your table for a record with that id. Those two bits of information should help troubleshoot.
Jun 28, 2022 05:44 AM
Thank you so much for your help