I have a workflow that creates 5 different subtasks via different transitions. I have a global 'Cancel' transition to close the task on the parent workflow and all sub-task worflows.
I have this built-in code from Adaptavist:
import com.atlassian.jira.component.ComponentAccessor
def issueService = ComponentAccessor.getIssueService()
def user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
def subTasks = issue.getSubTaskObjects()
subTasks.each {
if (it.statusObject.name == "Closed") {
def issueInputParameters = issueService.newIssueInputParameters()
issueInputParameters.with {
setResolutionId(10301) // resolution of "Fixed"
setComment("*Resolving* as a result of the *Resolve* action being applied to the parent.")
setSkipScreenCheck(true)
}
// validate and transition subtask
def validationResult = issueService.validateTransition(null, 10317, 41, issueInputParameters)
if (validationResult.isValid()) {
def issueResult = issueService.transition(user, validationResult)
if (!issueResult.isValid()) {
log.warn("Failed to transition subtask ${it.key}, errors: ${issueResult.errorCollection}")
}
} else {
log.warn("Could not transition subtask ${it.key}, errors: ${validationResult.errorCollection}")
}
}
}
When I test it, nothing is working, and the logs in the post function say that there are no problems. I have searched the internet and the community questions high and low for an answer but have had no luck.
Please may someone help me with what values I need to enter and where, and if this will close all my subtasks or if i need to copy certain bits of code and reuse them for different subtasks
There is this code which is meant to work:
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)
But the last line issueManager.deleteIssue(user, subTask, EventDispatchOption.ISSUE_DELETED, false) is not working (I have tried to find an updated version of this for Jria 7.1 and above but can't find it anywhere).
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.