Delete all subtasks of a parent issue as a workflow post function
Solution
- Use a ScriptRunner workflow post function to automatically delete all subtasks of a parent issue
Step-by-step guide
- Choose JIRA Admin and find or type "." and then "Workflows"
- Choose the Edit link under the Operations column for the workflow
- Choose the transition you want to alter
- Choose the Post Functions tab
- Choose Add post function link
- Click on the Script Post-Function radio button and then Add
- Click on the Custom script post-function link
- Add the below code to the "Inline script" blue text box
import com.atlassian.jira.component.ComponentAccessor import com.atlassian.jira.event.type.EventDispatchOption // for JIRA v6.* def user = ComponentAccessor.getJiraAuthenticationContext().user.directoryUser // for JIRA v7.* // def user = ComponentAccessor.getJiraAuthenticationContext().user def issueManager = ComponentAccessor.getIssueManager() // will return a Collection<Issue> with all the subtasks of the current issue def subTasksList = issue.getSubTaskObjects() for (subTask in subTasksList) { // add a condition here if you DO NOT want to delete all the sub-tasks issueManager.deleteIssue(user, subTask, EventDispatchOption.ISSUE_DELETED, false) }
Related articles