How to delete a row at a specific time

Hi thunkers,
I want my app to automatically delete a row every 7th day .
For example,to delete Row 1 in the Airtable spreadsheet every Monday morning…
I hope that’s clear ,TIA

You can use the “seconds since 1970” block and store its value in a stored variable. And then when the first screen opens, check to see if the value of that block is greater than 7 days’ worth of seconds plus the stored variable value.

There are 604,800 seconds in 7 days.

If you’re worried about people having the app open too long and the screen not triggering the “open” event, you could also check that value on a timer or when a navigation button is clicked, etc.

2 Likes

i will try that out.thanks

Is the app just for you or is it a shared app?
If it is a shared app then there’s a few things to keep in mind. If you use a timer, which is the best way, ALL open apps will be checking if it is time to delete the first row. So we need a way to check if the first row has already been removed or not, otherwise every app will just delete the 1st row and mess up the spreadsheet. To do this we need to have an identifier column in the spreadsheet, such as the date and time, ROW 1 should be removed (for example 8/18/2023 00:01.)

See my example:
AirtableDeleteRow

To do this we will need a variable list called “Identifier” that gets populated when the app opens and then again when the timer fires, say every 5 minutes. When the timer fires it will call the spreadsheet and update the identifier list. Then we can use the devices Time/Date blocks to get the current date and time and check if ROW 1 needs removed. If ROW 1 needs to be removed that users app will remove it. If all app users are in the same time zone you can use the device date and time blocks, otherwise you will need to use the seconds since 1970 block and do the math that way.

For example, if User 1’s app calls the spreadsheet which updates the identifier list and after checking the list it finds that ROW 1 shows 8/18/2023 00:01 and the device shows the current date/time is equal to or greater than 8/18/2023 00:01 it will remove ROW 1 from the spreadsheet. That way when User 2’s app calls the spreadsheet and get the current identifiers, ROW 1 will now show 8/19/2023 00:01) and will not remove ROW 1 at that time. I hope this helps you, if not someone else looking to do the same thing. Good luck!

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.