It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

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
Community showcase
Published in Marketplace Apps & Integrations

Marketplace Spotlight: Manage your assets with asset management apps

  The role of IT professionals has become increasingly difficult over the last decade. Our organizations work in an increasingly software-powered world and IT professionals are expected to not...

262 views 3 9
Read article

Community Events

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

Find an event

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

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you