The Atlassian Community can help you and your team get more value out of Atlassian products and practices.
For CloneIssue, it was enough for me to replace :
def params = [
issue : issue,
(CloneIssue.FIELD_TARGET_PROJECT) : issue.project.key,
(CloneIssue.FIELD_SELECTED_FIELDS) : null, //clone all the fields
] as Map<String, Object>
new CloneIssue().doScript(params)
with:
MutableIssue newIssue = ComponentAccessor.issueFactory.cloneIssueWithAllFields(issue)
newIssue.created = new Timestamp(System.currentTimeMillis())
Map<String,Object> newIssueParams = ["issue":newIssue] as Map<String,Object>
ComponentAccessor.issueManager.createIssueObject(issue.creator , newIssueParams)
Not sure how it worked for CreateSubTask. Here is a code snippet from my script:
MutableIssue newSubTask = ComponentAccessor.issueFactory.issue
newSubTask.setAssignee(ComponentAccessor.jiraAuthenticationContext.loggedInUser)
newSubTask.setSummary("Subtask for " + issue.key )
newSubTask.setDescription("Navigate to parent (eg. just click: [" + issue.key + "]) for details")
newSubTask.setParentObject(issue)
newSubTask.setProjectObject(issue.projectObject)
newSubTask.setIssueTypeId(ComponentAccessor.constantsManager.allIssueTypeObjects.find{ it.getName() == "Sub-approval"}.id)
// Add any other fields you want for the newly created sub task
Map newIssueParams = ["issue" : newSubTask] as Map
ComponentAccessor.issueManager.createIssueObject(ComponentAccessor.jiraAuthenticationContext.loggedInUser, newIssueParams)
ComponentAccessor.subTaskManager.createSubTaskIssueLink(issue, newSubTask, ComponentAccessor.jiraAuthenticationContext.loggedInUser)
I hope it helps :)
Connect with like-minded Atlassian users at free events near you!
Find an eventConnect with like-minded Atlassian users at free events near you!
Unfortunately there are no Community Events near you at the moment.
Host an eventYou're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events