We are using the clone issue link to clone tickets through a transition.
After cloning the ticket, it is required that the comments and attachment can be sent in both directions.
You can also synchronize attachments when they are added to comments .
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.link.IssueLink
import com.atlassian.jira.event.type.EventDispatchOption
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.event.issue.IssueEvent
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.issue.attachment.Attachment
import com.atlassian.jira.issue.AttachmentManager
import com.atlassian.jira.issue.comments.Comment
import com.atlassian.jira.issue.comments.CommentManager
import com.atlassian.jira.issue.link.IssueLinkManager
import com.atlassian.jira.issue.link.IssueLink
import com.atlassian.jira.user.ApplicationUser
import org.ofbiz.core.entity.GenericValue
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.Issue
//def attachmentManager = ComponentAccessor.getAttachmentManager()
//def lastAttachment = attachmentManager.getAttachments(issue).last()
//def issue = ComponentAccessor.getIssueManager().getIssueObject() //dummy issue - delete this
//String[] validLinkTypes = ["moved to", "cloned to"]
def linker = ComponentAccessor.getIssueLinkManager()
def commentMgr = ComponentAccessor.getCommentManager()
def issue = event.issue as MutableIssue
def project = issue.getProjectObject().getKey()
def attachmentManager = ComponentAccessor.getAttachmentManager()
def lastAttachment = attachmentManager.getAttachments(issue).last()
def issueLinks = linker.getOutwardLinks(issue.getId())
def subElements = issueLinks.findAll { it.issueLinkType.name.contains('cloned to') && it.issueLinkType.name.contains('moved to')
def newComment = event.getComment()
def originalAuthor = newComment.getAuthorApplicationUser()
def commentBody = newComment.getBody()
/*
subElements.each {
if( commentBody != "")
{
commentMgr.create(it.getDestinationObject(), originalAuthor, commentBody , false)
}
}*/
//subElements.each {
if(lastAttachment)
{
attachmentManager.copyAttachment(lastAttachment, originalAuthor, it.getDestinationObject().key)
}
//}
}
Do you have any suggestions on how to solve this requirement?