Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

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 auto close parent issue when all linked issues are closed using script runner

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 .


Harish Kumar

1 answer

2 votes
Leo Community Leader Dec 20, 2019

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.ComponentAccessor
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.user.ApplicationUser
import com.atlassian.jira.issue.IssueInputParametersImpl
import com.atlassian.jira.bc.issue.IssueService

def currentUser = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
def issueManager = ComponentAccessor.issueManager
IssueService issueService = ComponentAccessor.getIssueService()
def linkManager = ComponentAccessor.getIssueLinkManager()
def searchService = ComponentAccessor.getComponent(SearchService.class)
def actionId = 41 //41 is my final state transition ID

def transitionValidationResult
def transitionResult

if(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
transitionValidationResult = issueService.validateTransition(currentUser,, actionId,new IssueInputParametersImpl())
if (transitionValidationResult.isValid()) {
transitionResult = issueService.transition(currentUser, transitionValidationResult)
if (transitionResult.isValid())
{ log.warn("Transitioned issue $issue through action $actionId") }
{ log.warn("Transition result is not valid") }
log.warn("The transitionValidation is not valid")




Suggest an answer

Log in or Sign up to answer
Community showcase
Published in Trello

🏊‍♀️ Atlympic Event: Trello

Hello Community!  Quick disclaimer: We are running a contest on Community (The Atlympics!) from July 23rd - August 8th of 2021. If you are interested in participating in this contest (prizes! ...

106 views 1 11
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