I am unable to clone the issue using script runner

Hemalatha December 17, 2021

I am unable to clone the isssue using script runner, can you help me ?

1 answer

2 votes
Fabio Racobaldo _Herzum_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
December 17, 2021

Hi @Hemalatha ,

this code should clone your ticket. Please add your ticket key where "YOUR_SOURCE_TICKET_KEY_HERE".

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

def user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
def issueManager = ComponentAccessor.getIssueManager()
def issueObject = issueManager.getIssueByCurrentKey("YOUR_SOURCE_TICKET_KEY_HERE")
def clonedIssue = ComponentAccessor.getComponent(IssueFactory).cloneIssue(issueObject)

Map<String,Object> newIssueParams = ["issue" : clonedIssue] as Map<String,Object>
issueManager.createIssueObject(user, newIssueParams)
log.info "Issue with summary ${clonedIssue.key} created"

 Hope this helps,

Fabio

Suggest an answer

Log in or Sign up to answer