Forums

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

I Want automatically close all the subtasks when the parent issue is closed ?

Kumar
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.
September 12, 2018

Hi Team,

In project I have 4 different sub-tasks. Is there a way to close all subtasks when the parent Issue is closed ?Native solution, Plugin or Groovy script ?If yes, could you please provide the achieved code.

 

Thanks,

Phani

1 answer

0 votes
Mohamed Benziane
Community Champion
September 12, 2018
Kumar
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.
September 13, 2018

Hi @Mohamed Benziane  so I used the one query in that I just want know the sub-task I'd Where exactly I can find the Sub-task id so I have an 5 subtasks in my project here is query  can tell me the what else I can make changes in that query  

Can please help me 

Thanks,

Phani

import com.atlassian.jira.component.ComponentAccessor

def issueService = ComponentAccessor.getIssueService()
def user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()

def subTasks = issue.getSubTaskObjects()
subTasks.each {
if (it.statusObject.name == "Open") {
def issueInputParameters = issueService.newIssueInputParameters()
issueInputParameters.with {
setResolutionId("10000") // resolution of "Fixed"
setComment("*Resolving* as a result of the *Resolve* action being applied to the parent.")
setSkipScreenCheck(true)
}

// validate and transition subtask
def validationResult = issueService.validateTransition(user, it.id, 5, 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}")
}
}
}
Mohamed Benziane
Community Champion
September 13, 2018

HI @Kumar

 

Sorry i'm not a scriptrunner expert but if you want to retrieve an issueID i think this will help

 getUnderlyingIssue() 

Suggest an answer

Log in or Sign up to answer
TAGS
atlassian, out of office, loom, confluence, async collaboration, meeting recaps, remote teamwork, team alignment, knowledge sharing, AI-powered notes, productivity tools, workforce continuity, teamwork collection

Put your meeting notes on autopilot with Loom + Confluence

AI-powered meeting notes keep work moving even if you’re out of the office. Enjoy your well-deserved time off and return refreshed, confident you’ll catch up in no time.

Learn more
AUG Leaders

Atlassian Community Events