Updating Record on Airtable that has Attachment

Hi there,

I am trying to update a record in Airtable that has attachments and using the Update Record Airtable module. For the attachments, I can use “Add Item” where I can then add a filename and a URL and add items as I need them OR I could use map.

The issue with this is that sometimes I might only have two items to add, sometimes 3 or max 5. When I add five items, but only actually receive 3 from the array, then the module gives me an error :

The operation failed with an error. [422] Invalid attachment object for field Fotos: {}

For each item, I add use the following function(s):

{{if(get(map(2.array; "data"); "1.fileurl"); get(map(2.array; "data"); "1.fileurl"); )}}
{{if(get(map(2.array; "data"); "1.filename"); get(map(2.array; "data"); "1.filename"); )}}

For example :

In my example, the 5.fileurl and 5.filename are empty, so they will give an error.

What I would like to achieve is for them not to be used if they are empty, and simply use a dynamic way to add my files as attachments to update this field on the record. I could create a very “hard-coded” mapping where I count “the length of usable items” in array contains 1, 2, 3, 4, 5 and then for each create something I can use to map the array of objects.

1 Like

I solved it.

  1. I created a Text Aggregator after the search module and used { "filename":"{{53.data.filename}}", "url":"{{53.data.fileurl}}" } and used advanced and , as row separator.

  2. then I used a Parse JSON module with [{{74.text}}]

  3. then an Aggregator from the Pare JSON module using filename and url

  4. In my Update a Record module in the Fotos field I just used map and used the array of the Aggregator

This way it uploads nicely to Airtable.

4 Likes

Hey @dvf061 :wave:

Just wanted to pat you on the back for the awesome work you did while figuring out your problem. It’s so inspiring to see Makers learning to use our product more efficiently and smoothly.

Thank you for sharing your progress. This way our community stays tidy and neat for other users.

Keep up the great work! :sunny:

1 Like