The below script will delete all the subtasks associated with the issue that fired the listener event.
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.event.type.EventDispatchOption
def issueManager = ComponentAccessor.issueManager
def currentUser = ComponentAccessor.jiraAuthenticationContext.loggedInUser
// Get a list of the current issue's subtasks
def subtasks = issue.getSubTaskObjects()
// Loop through all the subtasks and delete them
subtasks.each {
issueManager.deleteIssue(currentUser, it, EventDispatchOption.ISSUE_DELETED, false)
}
Hi @Roland Holban (Adaptavist)
How would i change the code to only delete subtasks that begin with the word "Test" instead of deleting all subtasks?
E.g. I have subtasks such as Test Design, Test Execution, and i only want those subtasks to be deleted.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Inside the loop, you could add an if statement that checks whether the first 4 letters of the subtask's summary is "Test"
subtasks.each {
if (it.summary.substring(0,4) == "Test") {
issueManager.deleteIssue(currentUser, it, EventDispatchOption.ISSUE_DELETED, false)
}
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
This script will delete all the subtasks associated with the issue that fired the event.
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.event.type.EventDispatchOption
def issueManager = ComponentAccessor.issueManager
def currentUser = ComponentAccessor.jiraAuthenticationContext.loggedInUser
// Get a list of the current issue's subtasks
def subtasks = issue.getSubTaskObjects()
// Loop through all the subtasks and delete them
subtasks.each {
issueManager.deleteIssue(currentUser, it, EventDispatchOption.ISSUE_DELETED, false)
}
The last portion of the code shouldn't all be commented out. The Atlassian Community code block feature is really bad.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
The script below will delete all the subtasks associated with the issue that fired the listener event.
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.event.type.EventDispatchOption
def issueManager = ComponentAccessor.issueManager
def currentUser = ComponentAccessor.jiraAuthenticationContext.loggedInUser
// Get a list of the current issue's subtasks
def subtasks = issue.getSubTaskObjects()
// Loop through all the subtasks and delete them
subtasks.each {
issueManager.deleteIssue(currentUser, it, EventDispatchOption.ISSUE_DELETED, false)
}
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.