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

This widget could not be displayed.

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)
}

}
}

This widget could not be displayed.

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
Community showcase
Published Aug 22, 2018 in Marketplace Apps

How a Marketplace app tech team is achieving gender diversity

Hello! My name is Genevieve Blanch, and I'm the Marketing Manager at RefinedWiki, creators of apps to give teams the tools to customize Atlassian platforms. Currently, 44% of the tech team at Re...

509 views 3 18
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