Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Automatic closing of subtasks on cancelled issues

David Whitlock January 9, 2023

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.

1 answer

0 votes
Florian Bonniec
Community Champion
January 9, 2023

Hi @David Whitlock 

 

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

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
SERVER
VERSION
8.20.10
TAGS
AUG Leaders

Atlassian Community Events