How to close all sub-task when parent are closed.

How to close all sub-task when Parent are closed.

 

We are on JIRA 6.2.7 with Script Runner 3.0.16

Thanks

2 answers

Hey Vadim!

Check out this post-function script:

Auto-Close All Subtasks

Good luck!

Thanks Cody,

I run script but get error "

Error

startup failed: Script6.groovy: 33: expecting anything but ''\n''; got it anyway @ line 33, column 88. dationResult.errorCollection") ^ 1 error

org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed: Script6.groovy: 33: expecting anything but ''\n''; got it anyway @ line 33, column 88. dationResult.errorCollection") ^ 1 error

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.IssueInputParametersImpl
import com.atlassian.jira.config.SubTaskManager

Issue issue = issue
def constantManager = ComponentAccessor.getConstantsManager()
def issueService = ComponentAccessor.getIssueService()
def cwdUser = ComponentAccessor.jiraAuthenticationContext.getUser()

SubTaskManager subTaskManager = ComponentAccessor.getSubTaskManager()
Collection subTasks = issue.getSubTaskObjects()
if (subTaskManager.subTasksEnabled && !subTasks.empty) {
subTasks.each { Issue it ->
String comment = "*Resolving* as a result of the *Resolve* action being applied to the parent.";
def issueInputParameters = new IssueInputParametersImpl()

def doneResolutionId = constantManager.getResolutionObjects().find {it.name == "Done"}?.id
def doneStatusId = constantManager.getStatusObjects().find {it.name == "Done"}?.id

issueInputParameters.setResolutionId(doneResolutionId).setStatusId(doneStatusId).setComment(comment)

def transitionValidationResult = issueService.validateTransition(cwdUser, it.id, 21, issueInputParameters)
log.debug("Validation result : " , transitionValidationResult.errorCollection")
if (transitionValidationResult.isValid()) {
log.debug("Transition for sub task " + it.key + " is valid")
issueService.transition(cwdUser, transitionValidationResult)
}

}
}

Hi Vadim,

Just for info and future reference: the documentation has moved to a new site and this would be the link to Auto Close Subtasks if you are using a more recent version of JIRA (i.e version 7.x) and ScriptRunner (version 4.x).

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Published Jul 10, 2018 in Marketplace Apps

If you’re an Atlassian app developer, you’ll want to know about Atlas Camp!

This September 6-7, hundreds of Atlassian App developers will flock to Barcelona Spain to build skills, discover product roadmaps, meet face-to-face with the Atlassian team, and learn how to extend t...

167 views 0 4
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you