How to automatically remove attachments
Asked by Katerina Bohacova:

Hi, I am creating various rules to adjust my board. I have managed to automatically remove due dates and labels. However, I have not managed to create a rule automatically removing attachments. It is not an available option in the "add/remove" section of a new rule, or anywhere else. Can you please help me find it?  

Thanks a lot, Katerina


Answers:
author: Kyle Hatch
body: Hello, I would also like to support this request. We have cards for monthly supply orders that we attach a supply order list to. It would be nice when completing the card that it would automatically delete the attached old supply order list in addition to changing the due date and clearing the checklist. Thanks!

comments: author: Sal
body: Hi [@Kyle Hatch](/t5/user/viewprofilepage/user-id/5376769)! Thanks for your interest in this feature! I'll add your feedback as +1 to our internal feature request and bring visibility to your interest in having this option on Automation. Thanks for your understanding!


author: Luciana Munhoz
body: Hi Katerina! Welcome to the community!

I did some testing in here, but I couldn't find a way to directly remove an attachment like for labels and due dates. There's a way to use the attachment link.

So I tested an alternative that might help in your case. For that, I had to create 2 rules and use a custom field (available in Premium). Here it goes:

1 - Create a rule that when an attachment is added to a card, fill out the custom field with the attachment link. For that, I used the variable -\> *{attachmentlink}*  
*when an attachment is added to a card, set custom field "Attachment link" to "{attachmentlink}"*  
2 - Create a rule with a trigger (in this case I used a label to trigger an action) that will look for the attachment link in the custom field and remove the attachment from the card. Here used the variable {{%Custom Field name}}  
*when the blue label is added to a card, remove link "{{%Attachment link}}"*  
*![image (3).png](https://community.atlassian.com/t5/image/serverpage/image-id/254112i369912C1427B84B4/image-size/large?v=v2&px=999 "image (3).png")*  
The downside is that if you usually attach more than one doc to a card, it will be necessary to create more custom fields for each attachment.  
Here is some additional documentation that might help:   
<https://support.atlassian.com/trello/docs/butler-variables/>  
<https://support.atlassian.com/trello/docs/working-with-custom-fields/>  
Hope that helps! :)

comments: author: Katerina Bohacova
body: That would be the only think we would use Premium for and that is not really worth it. Thanks though.


author: Luciana Munhoz
body: Hi Katerina! I agree that would be great! I wanted to let you know that I checked internally and I see that we have this as a feature request in our backlog, so I have added your feedback as an official "+1" to that request! Hope this helps! If you have any additional insights into your workflow and how this feature would make Automation even more awesome, please don't hesitate to share. Thanks!


author: Felipe Mart?nez
body: Hi, I want to support that request. We have some rules for copying-linking cards, and we would like to automatically (upon a new trigger) remove the attached cards later (not possible currently). Greetings!


author: Luciana Munhoz
body: Hey Felipe! Thank you! Just added your feedback as a +1 as well. ;)


author: Chris Munoz
body: How would you implement the removal of a second (and possibly beyond) attachment using this method?


author: Luciana Munhoz
body: Hi Chris!

I understand that you want to remove a second attachment and so on, right? You can use the suggestion in this thread. However, you will need to create a custom field for each attachment. It's this suggestion [here](https://community.atlassian.com/t5/Trello-questions/How-to-automatically-remove-attachments/qaq-p/2341515#:~:text=The%20downside%20is%20that%20if%20you%20usually%20attach%20more%20than%20one%20doc%20to%20a%20card%2C%20it%20will%20be%20necessary%20to%20create%20more%20custom%20fields%20for%20each%20attachment.%C2%A0).


author: Chris Munoz
body: I've tried to follow that suggestion, but I am not able to properly format it so it actually removes the additional attachment. Is there wording that has to be added for it to be removed? The custom field doesn't allow for duplicates to be added, and I assume just adding a number or something after isn't sufficient enough for it to process correctly.


author: Luciana Munhoz
body: Hey Chris! Got it! I was testing here and to add more attachments you can change the automation a little bit.  

First, you'll need to create a custom field for each attachment you want to add. So, in case your card has 3 attachments, you'll create 3 Custom fields (like Attachment 1, Attachment 2, etc).  

Then, create an automation rule for each one using some filters to avoid one link overriding the other.  

Here's my example:  
![AttachmentRules.png](https://community.atlassian.com/t5/image/serverpage/image-id/331747iEC4168876C7A529A/image-dimensions/631x411?v=v2 "AttachmentRules.png")

Then to remove the attachment, you'll need to create a rule for each attachment that would be deleted using some labels as trigger. Here, I created 3 labels to correspond to each attachment.

Example:

![AttachmentRule1.png](https://community.atlassian.com/t5/image/serverpage/image-id/331748i97E74215D75DCBB6/image-size/large?v=v2&px=999 "AttachmentRule1.png")

Hope that helps!


author: Chris Munoz
body: It def helped, but I am coming across a single issue following this format. It seems to work half the time, while failing the rest. From what I can gather, it seems to fail when there are two different document types sent as an attachment (excel and PDF to be exact). It seems that If the excel is set to the attachment 1 slot, then both documents are removed. However, if the PDF is set at the attachment 1 slot, the process does not remove the excel as the second attachment. Is there any reason for this? Can the custom fields be used to removed specific document types so this issue does not occur again?


author: Chris Munoz
body: Actually I was able to get around this, but I had one issue remaining. It seems when I have two documents of the same type and are trying to separate them into different custom fields with the example shown above, it will put one in a custom field then replace it immediately with the second one. For example I have two custom fields Excel 1 and Excel 2. Using the process mentioned above, Excel 1 \& Excel 2 will be filled with the first attachment at the same time, but then gets replaced with the second attachment in both fields. When it comes to the label to remove them, only one gets truly removed while the other remains as an attachment as it is unable to remove it due to the link not matching. (All attachments are public items with nothing in the body)

![Test.PNG](https://community.atlassian.com/t5/image/serverpage/image-id/349111i2D7704CCD2376908/image-size/large?v=v2&px=999 "Test.PNG")![Test 2.PNG](https://community.atlassian.com/t5/image/serverpage/image-id/349112i9A643384AA4CDD67/image-size/large?v=v2&px=999 "Test 2.PNG")![Example.PNG](https://community.atlassian.com/t5/image/serverpage/image-id/349114iAEC42E63ACB60A9E/image-size/large?v=v2&px=999 "Example.PNG")


author: Carolina Lopez
body: Hi Chris,  

The behavior for all file extensions should be the same. Can you kindly check the [automation log](https://support.atlassian.com/trello/docs/opening-the-command-log/) for any error messages?  
Also, it would be really helpful if you could send us a screenshot of your rules. This will allow us to review them more easily.


author: Chris Munoz
body: Hi Carolina,

I had only went this method as it was actually effective in removing more than one document type. It seems when I use the example above, any document of the same type just gets replaced by the other. Screenshot is below, but as you can see, the XLSC file titled Sales by Flavor gets triggered then replaced by the other. When triggering the removal automation, only the one remaining in the custom field box gets removed.

![Activity report.PNG](https://community.atlassian.com/t5/image/serverpage/image-id/349325i73EF47F0863A5947/image-size/large?v=v2&px=999 "Activity report.PNG")

![Example 1.PNG](https://community.atlassian.com/t5/image/serverpage/image-id/349321i8ECA046DE8F5718A/image-size/large?v=v2&px=999 "Example 1.PNG")![Example 2.PNG](https://community.atlassian.com/t5/image/serverpage/image-id/349320i3339F4594ADDFF29/image-size/large?v=v2&px=999 "Example 2.PNG")