You can now vote for scripts to help people know if they're useful or not. Login or create an account to vote!


A post-function for deleting all subtasks of the current issue


You could use this if, for example, your subtasks represent transient objects that are no longer required at a later stage in the workflow, and you wish to delete them all on transition.

Set this up as a workflow post-function, putting it at the top of the list of post-functions.


  • Jira Jira (8.0 - 8.19)
  • ScriptRunner for Jira ScriptRunner for Jira (6.18.0)
import com.atlassian.jira.component.ComponentAccessor import com.atlassian.jira.event.type.EventDispatchOption import com.atlassian.jira.util.BuildUtilsInfo import org.ofbiz.core.entity.DelegatorInterface final int JIRA_8_9_0 = 809000 def user = ComponentAccessor.jiraAuthenticationContext.loggedInUser def issueManager = ComponentAccessor.issueManager def delegatorInterface = ComponentAccessor.getComponent(DelegatorInterface) def buildUtilsInfo = ComponentAccessor.getComponent(BuildUtilsInfo) def subTasks = issue.getSubTaskObjects() subTasks.each { subTask -> // add a condition here if you want to delete selective subtasks issueManager.deleteIssue(user, subTask, EventDispatchOption.ISSUE_DELETED, false) if (buildUtilsInfo.applicationBuildNumber >= JIRA_8_9_0) { delegatorInterface.removeByAnd("IssueVersion", [issueId:, deleted: 'Y']) } }
Discovered an issue? Report it here

Suggested for you