How to copy attachments to linked issue

I am looking for a way to copy attachments to a linked issue through post function. Basically , I am using "Create issue" post function to create issues in other projects . Though I am able to copy most of the fields, I also wanted to copy attachments to the newly created issue.

Is there a way to implement this using this JMWE add-on?

 

Many thanks!

Swathi

 

 

 

2 answers

This widget could not be displayed.
Peter DeWitt Community Champion Oct 27, 2017

@Swathi Komirelli [Appfire], take a look at this previous discussion.  It involves using Scriptrunner instead of JMWE but the key key is the scripting.  I believe the newest version of JMWE allows for groovy scripting as well.

https://community.atlassian.com/t5/Jira-Core-questions/Copy-attachments-to-one-issue-to-another-with-Scriptrunner-Cloud/qaq-p/31303

.pd

This widget could not be displayed.

Hello @Peter DeWitt , thanks for your inputs.

 

For users who could not use script runner ,please do watch this issue for updates:

https://innovalog.atlassian.net/browse/JMWE-504

 

A workaround is mentioned on this request. We make use of "Comment on linked issues" post function and add the following script as groovy expression : 

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.AttachmentManager
import com.atlassian.jira.issue.comments.Comment

def currentUser = ComponentAccessor.getJiraAuthenticationContext().getUser()
AttachmentManager attachmentManager = ComponentAccessor.getAttachmentManager();
attachmentManager.copyAttachments(issueObject, currentUser, linkedIssueObject.key);

Collection<Comment> comments = issue.get("comment");
if (comments==null || comments.isEmpty())
    return "";
return comments.last().body;

Place this post function after "Create/clone issue" post function (if you have this function defined).

Thanks,

Swathi

Suggest an answer

Log in or Sign up to answer
Atlassian Summit 2018

Meet the community IRL

Atlassian Summit is an excellent opportunity for in-person support, training, and networking.

Learn more
Community showcase
Posted Aug 06, 2018 in Jira Service Desk

A is for Activate: Share your top Jira Service Desk onboarding tips for new users!

Hi, everyone! Molly here from the Jira Service Desk Product Marketing Team :).  In the spirit of this month's  august-challenge, we're sourcing stories of Jira Service Desk activation fro...

578 views 25 15
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you