Coppy attachments via automation
Asked by Daniel Bermudez:

Hello, I have an issue when copying attachments from one ticket to another via automation.

I have an automation that copies attachments from a linked ticket to another. If I use only this automation, the attachments will keep duplicating in the destination ticket.

That's why in the Atlassian community, they suggested using another automation to delete the attachments from the destination ticket before copying them.

This works perfectly if I do it from the parent ticket to the child ticket, but if I try to do it the other way around, it doesn't work. The attachments get deleted, but then they don't get copied.

Do you have any idea what might be happening and how I could solve this?


Answers:
author: Trudy Claspill
body: Hello [@Daniel Bermudez](/t5/user/viewprofilepage/user-id/5254821)

When asking for help with an Automation rule that is not working, we need to see the actual rule in order to be able to help diagnose the problem.

Can you provide a screen image that shows the rule?

Also, please show us the details of an Audit Log entry for execution of the rule where you did not get the results you wanted.

comments: author: Daniel Bermudez
body: Hello [@Trudy Claspill](/t5/user/viewprofilepage/user-id/3569011) sure  

This is the automation that delete the attachments:

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

This is the audit log:

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

This is the automation that copy the attachments:

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

Audit log:

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

I just realized that the attachments are indeed being sent correctly, but then they get deleted. In other words, they are copied successfully to the parent ticket and then removed. I would need to reverse this process, deleting them first from the parent and then sending them from the child.


author: Trudy Claspill
body: Your second Audit Log image is the same as your first, for the Delete Attachments rule.

I can see a few potential problems.

1. If these are two separate rules then the rule adding of the attachments may be running before the rule that deletes the attachments.

2. Your rule doesn't have any criteria about the link types of the linked issues to be affected, but you mentioned a parent/child relationship. How do you specify that one is a parent (or child) of another?

3. Do you want to have only updates to the parent attachments copied to the child, or also updates to the child attachments copied to the parent? If the latter, can there be multiple children?

4. On the Rule Details page what is your setting for allowing the rule to be triggered by actions taken by other rules?


author: Daniel Bermudez
body: #1: Yes i think so, but if that is happening, why when I do this from parent to child it works properly?

#2: In the images not, but I tried specifing the link types and the result is the same, the link types of my issues are these, moved to, and cloned to:

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

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

In this case: DTS-22 Is the parent, and TEST-286 is the child

#3: I want both, thats why im having this problem, because it works when I send attachments from parent (DTS-22) to child (TEST-286) but it does not work the other way around child (TEST-286) to parent (DTS-22)

#4: Right now, I dont have that option enabled for any of the automations, but I tried to enable that option for the automation that copy the tickets, but it didnt work out


author: Trudy Claspill
body: #2: So you really want the attachments copied to all linked issues regardless of link type? By default Jira has several link types available, such as blocks, relates, and duplicates. The available link types are defined at

https://\<yourBaseURL\>/secure/admin/ViewLinkTypes!default.jspa

Can you provide a screen image of what you see on that page?

Generic issue linking does not confer a parent/child relationship from the perspective of Jira functionality. Considering one issue in the link a "parent" and the other a "child" is something that the users have to infer based on the link type used. In the image you provided which is the parent issue and which is the child issue?

Since an issue can have any number of linked issues, can your issues have more than one "parent", more than one "child", and can an issue have links such that you would consider it both a "parent" to some issues and a "child" of other issues.

I haven't worked out the details yet, but I suspect it would be more reliable if you had both the deletion of the attachments and the addition of the attachments happening in one rule. With two separate rules you have no control over which happens first, the deletion or the addition.


author: Daniel Bermudez
body: #2: Not really, just ones with the link type that we have configured as: Moved to and Cloned to, but I try with "All link types" just to see if with that it would work, but didnt.

I tried with just one automation too, but again, it didnt work out...

This is the automation that I tried:

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

This is what happens if i run that automation:

This is the parent ticket, I just placed the "screenshot=2.png"

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

And this is the result in the child ticket:

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


author: Trudy Claspill
body: So, one thing you need to do if you are using a single rule to both delete the attachments and then add them is add a Re-fetch Issue action in between the actions that delete and add the attachments.

You said you wanted to handle both of these scenarios:

1. When Attachments change in the "parent", delete the attachments in all the "children" and copy the attachments to them from the "parent".

2. When Attachments change in the "child", delete the attachments in the "parent" and copy the attachments to it from the "child".

Since an issue can have any number of linked issues, can your issues have more than one "parent", more than one "child", and can an issue have links such that you would consider it both a "parent" to some issues and a "child" of other issues.

If so, then concerning the second scenario, do you then expect the copying of attachments from the child to the parent to trigger scenario #1, with the new attachments in the parent then being copied to all its children? You could be setting up an endless loop with that.

https://\<yourBaseURL\>/secure/admin/ViewLinkTypes!default.jspa

Can you provide a screen image of what you see on that page?


author: Daniel Bermudez
body: Hello [@Trudy Claspill](/t5/user/viewprofilepage/user-id/3569011)


Tags: cloud

jira-service-management

jira-service-management-cloud