Hello everyone. How to clone subtasks from other issue? (using Groovy)
Hello @Andrew Striletskyi
You can use IssueFactory fow that
https://docs.atlassian.com/software/jira/docs/api/7.1.9/com/atlassian/jira/issue/IssueFactory.html
Yes , I know about. I have a situation when I want to create another issue. For example
def artifactIssue = issueManager.getIssueObject("TEST-2999")
def newArtifactIssue = issueFactory.cloneIssue(artifactIssue)
But It's not cloning an issue
clone issue just clone issue object, you need to create it after.
And for some reason it dont clone info about parent object, so you need to do that too.
Here the script:
import com.atlassian.jira.component.ComponentAccessordef issueManager = ComponentAccessor.getIssueManager()def issueFactory = ComponentAccessor.getIssueFactory()def subtaskManager = ComponentAccessor.getSubTaskManager()def issue = issueManager.getIssueObject("TEST-1")log.error("SOURCE ISSUE KEY: ${issue.getKey()}")def toclone = issueFactory.cloneIssueWithAllFields(issue)def cloned = issueManager.createIssueObject(issue.reporter, toclone)def parent = issueManager.getIssueObject(subtaskManager.getParentIssueId(issue))subtaskManager.createSubTaskIssueLink(parent, cloned, issue.reporter)log.error("CLONED ISSUE KEY: ${cloned.getKey()}")
Yes , It's OK for me. But last question: how to clone all subtasks of this issue?
I use the above code as well. But is there a way to return the sub-tasks in the order in which they're placed in the to-be-cloned issue? Because for us, order matters in terms of the order in which you execute sub-tasks, and that order is lost when cloning sub-tasks.
It looks like they're returned to the caller in the order in which they were created, not the order in which they were placed.
It looks like you're new here. Sign in or register to get started.