You're on your way to the next level! Join the Kudos program to earn points and save your progress.
Level 1: Seed
25 / 150 points
Next: Root
1 badge earned
Challenges come and go, but your rewards stay with you. Do more to earn more!
What goes around comes around! Share the love by gifting kudos to your peers.
Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!
Join now to unlock these features and more
The Atlassian Community can help you and your team get more value out of Atlassian products and practices.
I am having a tough time finding an example of how to do this, but I need to add a post function script for sub-task issue types that moves the current sub-task from the existing parent ID to a fixed parent ID. Any help would be appreciated.
Hi @Stephen Higgins
Try use subtaskManager.changeParent method.
You can test this example script via Script Console:
import com.atlassian.jira.component.ComponentAccessor
def issueManager = ComponentAccessor.issueManager
def subtaskManager = ComponentAccessor.subTaskManager
//get old parent issue
def oldParentIssue = issueManager.getIssueObject("AA-338")
//get new parent issue
def newParentIssue = issueManager.getIssueObject("AA-339")
//get old parent subtasks
def subtasks = oldParentIssue.getSubTaskObjects()
//logged in user
def currentUser = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
subtasks.each { child ->
//update all subtasks to a new parent issue
subtaskManager.changeParent(child, newParentIssue, currentUser)
}
Another example, if run in the post-function:
import com.atlassian.jira.component.ComponentAccessor
def issueManager = ComponentAccessor.issueManager
def subtaskManager = ComponentAccessor.subTaskManager
//get new parent issue
def newParentIssue = issueManager.getIssueObject("AA-339")
def currentUser = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
if(issue.subTask)
{
subtaskManager.changeParent(issue, newParentIssue, currentUser)
}
I hope this helps.
Sorry to ask directly on this answer here, but would this work if new parent is from another project?so, is it possible to link to a parent on another project f.e. changing parent from AA-338 to BB-339
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.