Hello, I have 2 items I am attempting resolve and hoping to get some guidance.
1) I was looking at behaviors to attempt to close subtasks on issues that were cancelled, but behaviors do not seem to be able to do that. Is there a way of automatically closing these subtasks?
2) Is there a bulk way of closing sub tasks on issues already cancelled?
Thank you.
Yes it's possible to do it with automation for JIRA. Are you using JIRA Data Center ? The app is included into it.
You can also do it using Scriptrunner by using a script.
You should be able to run a script in the postfunction that Cancel the parent issue.
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.config.ResolutionManager
log.setLevel(org.apache.log4j.Level.DEBUG)
def issueService = ComponentAccessor.getIssueService()
def user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
def resolutionManager = ComponentAccessor.getComponent(ResolutionManager)
def closingResolution = issue.getResolutionObject()?.getId()
def subtaskTransitionId = 111 //Replace with your transition ID
def subTasks = issue.getSubTaskObjects()
subTasks.each {
if (!it.getResolution()) {
def issueInputParameters = issueService.newIssueInputParameters()
issueInputParameters.with {
setResolutionId(closingResolution)
setSkipScreenCheck(true)
}
def validationResult = issueService.validateTransition(user, it.id, subtaskTransitionId, 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}")
}
}
}
Regards
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.