Skip to main content
Question

Problem with replacing attachments in Asana tasks (V.2)

  • 3 June 2024
  • 2 replies
  • 12 views

Dear all,

This is part 2 of our process of creating a solution for attaching social media image files to new Asana tasks.

We have made some progress after some extremely helpful suggestions from the community in Part 1 of this post, however, when we posed a few follow-up questions, there were no more responses, which seemed to us like the post updates were not visible to reviewers. Therefore, we wanted to reach out for help in this new post.

 

Context

We have created a Zap that attaches social media image files to Asana tasks. It either creates new Asana tasks where the file name is new, or attached to existing task. Our problem is that if we have new versions of already attached files, we have to manually remove them and attach new versions - we have to change the zap to automate that too.

 

The current steps of the Zap are as follows:

  1. File fullName is added to the G Drive folder.
  2. Truncate the first 4 digits of fullNametruncName. This is the name of the Asana task.
  3. ‘Delay after queue', so that Zap waits for the previous file to be processed before starting with the next one. They have to be executed consecutively, otherwise it doesn’t find the tasks with the same name and creates duplicates.
  4. Find a task in Asana with the title truncName. If no such task, create the task truncName.
  5. Attach the file fullName to the truncName Asana task.

Here’s the zap:

 

 

Now, we frequently have new versions of attachments that arrive from client feedback. Therefore, we have to be able to drop in the file with the same fullName to Google Folder and have the zap to automatically delete the old attachment, and attach the new file instead.

For that, we’ve created and tested two custom actions:

  1. Get attachments for the Asana task. This action picks up the task ID from step 2 and returns the attachments as an array of IDs and filenames: n{"gid":"1207413011329099","name":"S999-1.jpg"},{"gid":"1207413011329101","name":"S999-2.jpg"}]
  2. Delete an Attachment. This action requires the GID found by the previous action and deletes the attachment.

Here’s a screenshot for the Get Attachments Action:

 

 

Our problem is now how to combine those two steps. I suppose that we need another action here that would go through the array above, compare it to the full filename of the file just added, and if the two names match, it would return the GID for that specific file.

Example 1 (attachment with this name exists):

  • Array: t{"gid":"1207413011329099","name":"S999-1.jpg"},{"gid":"1207413011329101","name":"S999-2.jpg"}]
  • Filename: S999-1.jpg
  • Match: TRUE
  • Output: 1207413011329099

Example 2 (no attachment with this name exists): 

  • Array: h{"gid":"1207413011329099","name":"S999-1.jpg"},{"gid":"1207413011329101","name":"S999-2.jpg"}]
  • Filename: S998.jpg
  • Match: FALSE
  • Output: FALSE

With these results, if GID is returned, delete the file. If not, skip the Delete step and proceed to Attach the file.

 

So overall, the updated Zap could look like this (new steps in red):

  1. File fullName is added to the G Drive folder.
  2. Truncate the first 4 digits of fullNametruncName.
  3. ‘Delay after queue', so that Zap waits for the previous file to be processed before starting with the next one. They have to be executed consecutively, otherwise it doesn’t find the tasks with the same name and creates duplicates.
  4. Find a task in Asana with the title truncName. If no such task, create the task truncName.
  5. Get the list of attachments for task truncName. (Custom Action is tested and working)
  6. Verify if the file fullName is present in the list of attachments. If exists, return its GID, if not, return False.
  7. If GID exists, delete the attachment, if not, skip this step.  (Custom Action is tested and working + Zapier Path to split the if/else condition)
  8. Attach the file fullName to truncName Asana task.

 

Thus, our main question is about step 6 - how can this be realised?

But also let me know if you have any overall suggestions for steps 5-7. Very much appreciate your help!

 

 

2 replies

Userlevel 7
Badge +14

Hi @pilotinstitute 

Try using the Looping app to iterate thru the array of items: https://zapier.com/apps/looping/help

thank you very much @Troy Tessalone for the advice, and apologies for the late reply - let me test this app and get back with results!

Reply