Example scripts
To homepage
Jira

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

ScriptRunner For Jira
by Adaptavist
Compatibility

Jira (8.0 - 8.19)

ScriptRunner For Jira (7.10.0)
Language |
groovy
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.getLoggedInUser()
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: subTask.id, deleted: 'Y'])
}
}
Having an issue with this script?
Report it here