How to clone issue and link the following issue

Andrew Striletskyi November 5, 2018

Hello everyone. I have a part of code to "copy issue" to another queue and I want to link the following issue. How to do that (I can't even get new issue id from another project)

 

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.Issue


def PROJECT_KEY_TO = "SOME PROJECT"

def issueManager = ComponentAccessor.getIssueManager()
def user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
def issueFactory = ComponentAccessor.getIssueFactory()
def issueLinkManager = ComponentAccessor.getIssueLinkManager()

def projectTo = ComponentAccessor.getProjectManager().getProjectByCurrentKey(PROJECT_KEY_TO)

if (issue.summary.contains("*some summary*") {
def newIssue = issueFactory.cloneIssue(issue)

newIssue.setProjectObject(projectTo)

Map <String,Object> newIssueParams = ["issue":newIssue] as Map<String,Object>
Issue storageIssue = issueManager.createIssueObject(user, newIssueParams)
log.error(storageIssue.id)

}

 

 

1 answer

0 votes
Fadoua
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
November 5, 2018

@Andrew Striletskyi

What are you trying to achieve exactly? You can clone an issue without coding.

Best,

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events