Question

How can I attach multiple files from a single cell with comma-separated references in a Google Sheets row?

  • 29 June 2023
  • 6 replies
  • 156 views

Userlevel 1
Badge +1

I have a Form that allows users to upload multiple docs.  It then creates a sheets row, with a single cell that contains a link to the docs stored in the Google drive.  Troy Tessalone helped me to get Zappier to attach the doc to the gmail - it works great.  And looks like this:

Now I need to do the same thing with the single cell that has multiple file references separated by comma’s. 

 

 

My first thought was to use the “Text in Formatter” - and it breaks up the single cell of into into it’s components - perfect. 

 

 

Then I need to pass each one of those through a second formatter to change the links to actually attach the files instead of the link, then attach those to the email.  There might be a single file, or all the way up to 10.

I was thinking that loops would be a good way to run through each file and reformat it, I have no idea what to put in the values to loop entry, then it seems like I can’t select all the output items… which makes me think it’s not the right process to use. 

 

 

If I can’t use loops what would the best approach be?  10 separate instances of Formatter to replace each possible file reference?  Doesn’t seem that elegant, and I’m thinking there is a better way that I’m missing.

 

 


This post has been closed for comments. Please create a new post if you need help or have a question about this topic.

6 replies

Userlevel 7
Badge +14

Hi @Leithal 

Good question.

The Formatter > Text > Replace action can handle line items.

Userlevel 1
Badge +1

Troy - we meet again 🙂

I started this as a new post since it was a different issue/goal.

So as you mentioned I looked at Formatter - I’m getting the response I’m looking for, but I’m not sure how to progress from here.

 

I have the three values, but might be up to ten.

So I started with Formatter to remove the beginning portion of the URL, so I can get the document ID, then assemble into the synthetic variables for the GMail portion.

 

First - it looks like I’d have to address each element individually, I’d have to create a test record with 10 attachments (which is no issue) but looking ahead in the process I’d have to have some conditional on each attachment on the Gmail/email function since I wouldn’t want to attempt to “attach” element 6 if there are only 5, I imagine it would error out the gmail function.

 

It would be more efficient to do a for/next do/while or similar loop, which lead me to loops - but that doesn't seem to be a fit. I might be wrong, but it seems that would fit if I wanted to send an email for each attachment, but I need all attachments in a single email.

Is it possible to loop through the elements? And if so how do you only add attachments 1-N and not have N+1 entries on the Gmail action.

 

Userlevel 7
Badge +14

@Leithal 

You can map the output from the Formatter step to the Gmail Send Email > Attachments field, which handles line items.

Userlevel 1
Badge +1

So that means that:

  1. I will create a spreadsheet row with 10 attachments - the maximum, to test etc.
  2. I will create 10 formatter steps, one for each attachment (to strip the non-document info)
  3. I will then create the email with 10 possible attachments, combining the document info with the URL info to make an attachment. And since the attachement will be two parts (URL and Document) the attachment process will fail on any of the empty entries.  And that “shouldn’t” affect the sending of the email.

 

I’ll give it a go.  Seems to be very cumbersome.  If I had 100 attachments that would be 100 stripping steps, then 100 lines in the Gmail.  I’m really surprised there isn’t an iterative way to handle this, or possibly some array solution.

 

Userlevel 7
Badge +14

@Leithal 

I will create 10 formatter steps, one for each attachment (to strip the non-document info)

You’ll probably need to use a Code step to handle the variable # of links from 1-10.

The Code step can be used to format the links and body content.

 

The Gmail Send Email > Attachments field expects publicly accessible URLs.

 

If you need help, consider hiring a Certified Zapier Expert: https://zapier.com/experts/automation-ace

Userlevel 7
Badge +11

Hi @Leithal

Were you able to sort things out using a Code by Zapier action or by enlisting the help of a Certified Zapier Expert as Troy suggested?

Keen to ensure you’re all set here! 🙂