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

Vadim Sakhray May 10, 2016

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

2 votes
105349
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 10, 2016

Hey Vadim!

Check out this post-function script:

Auto-Close All Subtasks

Good luck!

Vadim Sakhray May 11, 2016

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
Vadim Sakhray May 11, 2016

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

}
}

0 votes
Mark McCormack _Adaptavist_
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 10, 2016

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

105349
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 11, 2016

Thanks Mark!

Vadim Sakhray May 12, 2016

Thanks Mark!

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events