How to auto close an parent issue when all its subtasks are closed in the same project.
I am trying this by using script runner for JIRA.
Can you guys help me out from here .
Thanks
Harish Kumar
Hi @Harish Kumar,
There is built-in post-function available in scriptrunner called "Transition parent when all subtasks are resolved"
and below script also can do the same for you
import com.atlassian.jira.component.ComponentAccessorimport com.atlassian.jira.issue.MutableIssueimport com.atlassian.jira.user.ApplicationUserimport com.atlassian.jira.issue.IssueInputParametersImplimport com.atlassian.jira.bc.issue.search.SearchServiceimport com.atlassian.jira.bc.issue.IssueServicedef currentUser = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()def issueManager = ComponentAccessor.issueManagerIssueService issueService = ComponentAccessor.getIssueService()def linkManager = ComponentAccessor.getIssueLinkManager()def searchService = ComponentAccessor.getComponent(SearchService.class)def actionId = 41 //41 is my final state transition IDdef transitionValidationResultdef transitionResultif(issue.getIssueType().name == "Sub-task"){ def allDone = true ApplicationUser user = issue.getAssignee() def parent = issue.getParentObject() parent.getSubTaskObjects()?.each { subtask -> if(subtask.getStatus().name == "Unresolved" && subtask != issue) { allDone = false } } if(allDone){ transitionValidationResult = issueService.validateTransition(currentUser, parent.id, actionId,new IssueInputParametersImpl()) if (transitionValidationResult.isValid()) { transitionResult = issueService.transition(currentUser, transitionValidationResult) if (transitionResult.isValid()) { log.warn("Transitioned issue $issue through action $actionId") } else { log.warn("Transition result is not valid") } }else{ log.warn("The transitionValidation is not valid") } } }
BR,
Leo
hey @Leo , where should we paste the script you gave above?
It looks like you're new here. Sign in or register to get started.