Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

How to copy attachments on subtask up to the parent ticket

Lauren Robinette
Contributor
January 10, 2019

Is it possible to copy attachments that are posted to the subtask ticket up to the parent ticket without erasing any of the attachments on the parent ticket?

1 answer

0 votes
Ivan Tovbin
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 10, 2019

Hi Lauren,

I'm afraid you can't do this with basic jira functionality which is available out of the box. You'll need 3rd party addons like Scriptrunner, Power Scripts or Automation for Jira to achieve this.

Lauren Robinette
Contributor
January 10, 2019

hi @Ivan Tovbin! I have both Scriptrunner and Automation for Jira. Could you walk me through how to use either one of them to build a subtask off of a subtask if one field on the first subtask has a certain selection? I'm using Jira Server.

Ivan Tovbin
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 10, 2019

Sure thing. When exactly do you want this to trigger?

Lauren Robinette
Contributor
January 11, 2019

@Ivan Tovbin When the ticket is moved to Done

Ivan Tovbin
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 11, 2019

I see. It seems a scripted post function is the solution here. Here's the code. Use it for a scripted post function on a transition which is used to move a ticket to 'Done' status:

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.AttachmentManager
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.attachment.Attachment
import com.atlassian.jira.user.ApplicationUser

ApplicationUser currentUser = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
Issue parentIssue = issue.getParentObject()
AttachmentManager attachmentManager = ComponentAccessor.getAttachmentManager()
Collection<Attachment> attachments = issue.getAttachments()

attachments.each{
attachmentManager.copyAttachment(it, currentUser, parentIssue.getKey())
}
Like # people like this

Suggest an answer

Log in or Sign up to answer