Airtable Cobuilder is here! Learn more about our new no-code app creation feature, powered by AI on the Airtable Academy
Dec 15, 2022 10:17 AM
Is there a way for tables data to clear at a certain time each day automatically?
Dec 15, 2022 12:55 PM
Sure can, but you'll always need a scripting action to run the deletion.
For a simple table that looks like this;
We can delete an array of records by using;
The code may look something like this;
const {deleteRecordIds} = input.config();
const table = base.getTable("Delete Records");
await table.deleteRecordsAsync(deleteRecordIds);
With the input of records to delete array coming from the no-code action "Find Records";
The Automation can be set to run on a time, find records that meet your deletion criteria, and delete them.
Deleting records in one big batch has the major advantage of being easily recovered from the trash with one click;
Dec 15, 2022 05:26 PM
The system that @Karlstens wrote will only work if there are less than 50 records to delete. This is due to two issues:
- The "deleteRecordsAsync" function only accepts a maximum of 50 records.
- The "Find Records" action can find a maximum of 100 records.
Instead, if you want a low code solution, I recommend having a filtered view that shows only the records to. be deleted, and then run a script that deletes all the records in the view. A couple of different versions of such a script have been posted on the forums in the past. I am not able to search for them since the change to the new forum platform, but I am on a mobile device. If you are able to search for them, could you please add the link in a reply to this topic? That will help future users who might have the same question.
Dec 16, 2022 05:54 AM
I can't find the old topic