Help

Re: Automating Airtable Scripts

2806 0
cancel
Showing results for 
Search instead for 
Did you mean: 
booo_Urns
4 - Data Explorer
4 - Data Explorer

I’m currently using the Airtable script ‘Convert URL’s To Attachments’ to populate a column w/in my table with images coming from a URL.

My table’s data is refreshed once per hour - so currently my images need to be downloaded after each refresh (manual at the moment)

I’m trying to automate this process by using this script w/in the Automations settings for my base but do not see a way to select an existing script when setting up the automation.

16 Replies 16

Welcome to the Airtable community!

When creating an automation script, you can copy/paste the script code into the script editor. However, many scripts that are written for Scripting App cannot be used as-is in an automation. The 'Convert URL’s To Attachments’ script would need major changes to be able to be used in an automation. In fact, the changes are so dramatic, that it may be easier to write a new script from scratch.

If you are replacing attachments every hour, you may also be using up your attachment storage limit rather quickly. Old deleted attachments are not automatically deleted by Airtable and continue to count towards your base’s quota. Airtable has not published now long old, deleted attachments remain, but a reasonable guess is at least one year (the length of revision history) without manual intervention by support.

Hey there!

If you want an easier way to do this, you can use the Convert URL to Attachment Function in the On2Air Actions app.

You can use it inside an Automation. It will automatically generate a script for you. All you need to do is then add the script in the ‘Run Script’ option in your automation.

With Actions, you also get an additional 60+ functions for Airtable

______________________________________
Hannah - On2Air.com - Automated Backups for Airtable

So you are saying that if I have a field with a URL - and I download the attachment in that field - and then refresh my data so that the attachment is no longer in the field - - that the attachment is still stored somewhere but I cannot see/use it and it counts towards some storage quota ?

If i am going to create a script for this, is there some existing function to download an attachment from a url that I can work from? Was not able to find

Yes. You can test this out for yourself.

  1. Upload an attachment. Get the url for where the attachment is stored on Airtable’s servers by using a formula field with the attachment field name.
  2. Copy the url to a temporary location outside of Airtable.
  3. Delete that attachment from Airtable.
  4. In a browser window, view the url. The attachment will still be there.

With a Pro plan, you can have up to 20GB of attachment storage per base. Depending on the size of the attachments, this can be used up quickly, especially if you are creating new attachments every hour.

If you are interested in writing your own script, you can see the developer reference documentation. Here is the format for an attachment field.

I’ve not delved into the guts of revision history yet, but this discussion has piqued my interest, partly because I’m trying to help a client who has hit an attachment limit. Does it affect the quota when record revision history is deleted? I’m running a test now to see for myself, but the stats on my workspace settings page aren’t refreshing as promptly as I’d hoped (and I’ve reloaded the page multiple times). The base where I’m running the test shows 6.9MB of attachments, but that only accounts for the existing attachments before the 112MB file that I just added. I want to see how that indicator changes when I delete the test record (and its attachment) along with record revision history, and I hope that I don’t have to wait a full day for that figure to refresh.

Edit: it just updated. Maybe it’s a similar 10- to 15-minute refresh frequency like so many other things. I’ll report back once I see the final results from my test.

It worked. The record and its attachment are gone, record revision history was deleted, and that base is showing its original attachment size of 6.9MB on the workspace settings page.

Awesome. Thanks for the tests @Justin_Barrett. Good to know that deleting record revision history will free up attachment space. Can you tell if it actually deletes the attachment from the server, or is the attachment still publicly available (even if it doesn’t count towards your attachment limit)?

My money is on “No” and I hope I am wrong. If wrong, I would happily pay it forward with a sandwich for those who care to bet in advance of the answer from @Justin_Barrett.