Skip to main content
Solved

Script to clear all records or table

  • October 29, 2024
  • 6 replies
  • 90 views

Forum|alt.badge.img+4

Any way to clear all records or delete a table through script?

This don't work:

do
{
let table = base.tables.pop();
console.log(`Goodbye, ${table.name}!`);
}
while(base.tables.length>0)

 

Best answer by Mike_AutomaticN

Hey @renewNiko!

I just sent you my own version of the script via PM, in case @kuovonne did not send that over yet :D.

Best,
Mike, Consultant @ Automatic Nation

6 replies

kuovonne
Forum|alt.badge.img+29
  • Brainy
  • 6009 replies
  • October 29, 2024

Yes, it is possible to delete all records in a table through a script. The script is actually a very simple one; however, because it is so destructive, I don't feel comfortable posting a version.

 

It is not possible to delete the table itself via scripting.

Where did you get the code you posted? It looks like code for removing items from an array one at a time, which is very different from deleting an actual table.

Would you care to share why you want to delete all the records in a table or delete the table itself via code? Usually these things are done very infrequently and thus can be done via human interaction.


Forum|alt.badge.img+4
  • Author
  • New Participant
  • 2 replies
  • October 29, 2024

Yes, it is possible to delete all records in a table through a script. The script is actually a very simple one; however, because it is so destructive, I don't feel comfortable posting a version.

 

It is not possible to delete the table itself via scripting.

Where did you get the code you posted? It looks like code for removing items from an array one at a time, which is very different from deleting an actual table.

Would you care to share why you want to delete all the records in a table or delete the table itself via code? Usually these things are done very infrequently and thus can be done via human interaction.


Thank you for the reply. There is a third-party integrations that feeds data and they can't keep track of changes/new rows in the data so they send everything. Therefore, I would like to empty the table every day.

I would be grateful if you posted that simple script. PM me if you like, the risk is on me 🙂

ps
the script I posted was something I just came up with just using IntelliSense...


Mike_AutomaticN
Forum|alt.badge.img+28
  • Genius
  • 1547 replies
  • Answer
  • October 29, 2024

Hey @renewNiko!

I just sent you my own version of the script via PM, in case @kuovonne did not send that over yet :D.

Best,
Mike, Consultant @ Automatic Nation


kuovonne
Forum|alt.badge.img+29
  • Brainy
  • 6009 replies
  • October 29, 2024

Thank you for the reply. There is a third-party integrations that feeds data and they can't keep track of changes/new rows in the data so they send everything. Therefore, I would like to empty the table every day.

I would be grateful if you posted that simple script. PM me if you like, the risk is on me 🙂

ps
the script I posted was something I just came up with just using IntelliSense...



@renewNiko wrote:

the script I posted was something I just came up with just using IntelliSense...


Thank you for saying how you got the code. Looks like IntelliSense doesn't know anything about the Airtable scripting environment. I would not trust it to come up with an Airtable script.


Forum|alt.badge.img+4
  • Author
  • New Participant
  • 2 replies
  • October 29, 2024

Hey @renewNiko!

I just sent you my own version of the script via PM, in case @kuovonne did not send that over yet :D.

Best,
Mike, Consultant @ Automatic Nation


Thanks Mike! 👍


Forum|alt.badge.img+2
  • New Participant
  • 1 reply
  • November 13, 2024

Hey @renewNiko!

I just sent you my own version of the script via PM, in case @kuovonne did not send that over yet :D.

Best,
Mike, Consultant @ Automatic Nation


Hello Mike, can you send me the script too? 🙂