---
title: "Copy the attachments of the linked issues to the current issue"
canonical: "https://support.appfire.com/space/JMWE/461996604/Copy%20the%20attachments%20of%20the%20linked%20issues%20to%20the%20current%20issue"
format: markdown
---
> Macro (aura-html)

> ⚠️ This document is obsolete. JMWE now supports copying of attachments across issues in the post-functions.

### Abstract

This code snippet copies Attachments to the current issue from issues linked to it with a specific link type. Since currently copying and setting of attachments is not supported until [JMWE-504](https://appfire.atlassian.net/browse/JMWE-504) is implemented, you can use this snippet to copy the attachments.

### Logic

Fetch the attachments of the linked issues, linked to the current issue with a specific link type and use the `AttachmentManager` to copy them.

### Snippet

```groovy
//Initialize the attachmentManager
import com.atlassian.jira.issue.AttachmentManager
AttachmentManager attachmentManager = ComponentAccessor.getAttachmentManager()

//Define a variable to store the attachments 
def attach = []
if(issue.getLinkedIssues("<Link type name>")){
//Fetch the attachments of the linked issue and store them in the attach variable
  issue.getLinkedIssues("<Link type name>").each{
    attach += it.get("attachment")
  }
}
//Add each attachment to the issue
attach.each{
  attachmentManager.copyAttachment(it,currentUser,issue.key)
}
```

> ℹ️ By not specifying the link type, as `issue.getLinkedIssues(), `you can copy the Attachments of all the linked issues of the current issue, <span style="color: #333333">other than the Parent-Subtask and Epic-Story links</span>.

### Placeholders

| **Placeholder** | **Description** | **Example** |
| --- | --- | --- |
| `<Link type name`> | Name of the link type | `is cloned by` |

### Examples

<span style="color: #333333">The outcome of the code snippet is the copy of </span>Attachments to an issue in the Scripted Groovy post-function:

- Copy the Attachments of the current issue to its newly created linked issue created using the Create issue post-function
- <span style="color: #333333">Copy the Attachments of the issue to a linked issue</span>

### References

- [issue variable](https://appfire.atlassian.net/wiki/spaces/JMWE/pages/78055921)
- [getLinkedIssues()](https://appfire.atlassian.net/wiki/spaces/JMWE/pages/78055970)
- [Accessing the fields of an issue](https://appfire.atlassian.net/wiki/spaces/JMWE/pages/78055905)
- [**Groovy Documentation**](http://groovy.codehaus.org/User+Guide)

### Related articles

> Macro (contentbylabel)