Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Deleted user
0 / 0 points
badges earned

Your Points Tracker
  • Global
  • Feed

Badge for your thoughts?

You're enrolled in our new beta rewards program. Join our group to get the inside scoop and share your feedback.

Join group
Give the gift of kudos
You have 0 kudos available to give
Who do you want to recognize?
Why do you want to recognize them?
Great job appreciating your peers!
Check back soon to give more kudos.

Past Kudos Given
No kudos given
You haven't given any kudos yet. Share the love above and you'll see it here.

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

ScriptRunner how to automatically transition an Epic to Completion when all its children are complet

Hello Community,

I am trying to develop a ScriptRunner Script that will allow me to transition an Epic to completion once all of the Stories/Tasks/Defects/Subtasks under it are completed.

Could someone point me in the right direction to achieve such functionality.

I appreciate your help!


1 answer

1 accepted

4 votes
Answer accepted

Hi Roberto, 

Hopefully is not too late but I crafted a post function, that should be put into the "Closed" step in the workflow. Hopefully you will understand the logic from the comments added in the code, if not, please shout :)

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.IssueInputParameters
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.user.ApplicationUser
import com.atlassian.jira.workflow.TransitionOptions

def issue = issue as MutableIssue
def user = ComponentAccessor.userManager.getUserByKey("admin")

parentIssue = issue.isSubTask() ? issue.parentObject :
ComponentAccessor.getIssueLinkManager().getInwardLinks( { == "Epic-Story Link"}?.sourceObject

if (!parentIssue) {
// there is not any Epic issue as source so do nothing

log.debug "Parent issue $parentIssue"

// check if the parent issue has any subtasks that are not closed
def openSubtasks = parentIssue?.subTaskObjects?.findAll { != "Done"}

log.debug "Open subtasks $openSubtasks"
// if there are subtasks that are not open (apart from the one in transition) - then do nothing
if (openSubtasks - issue) {

// get all the open linked (with the epic-story link) issues and are not closed
def linkedIssues = ComponentAccessor.getIssueLinkManager().getOutwardLinks( { == "Epic-Story Link"}*.destinationObject?.findAll { != "Done"}

log.debug "Open linded issues $linkedIssues"
// if there are linked issues that are open (apart from the one in transition) - then do nothing
if (linkedIssues - issue) {

// if the script reached here means that all the subtasks and the linked - with the Epic Story link - issues are closed
// therefore transit the issue
transitIssue(parentIssue, 41, user)

def transitIssue(Issue issue, int actionId, ApplicationUser cwdUser) {
def issueService = ComponentAccessor.getIssueService()

IssueInputParameters issueInputParameters = issueService.newIssueInputParameters()
issueInputParameters.setComment("This is a comment")

def transitionOptions= new TransitionOptions.Builder()

def transitionValidationResult =
issueService.validateTransition(cwdUser,, actionId, issueInputParameters, transitionOptions)

if (transitionValidationResult.isValid()) {
return issueService.transition(cwdUser, transitionValidationResult).getIssue()

log.error "Transition of issue ${issue.key} failed. " + transitionValidationResult.errorCollection

Please let me know if this does the trick.



Hello Thanos,


thank you for sharing your programming code. I've tried it but it didn't work at our company. I guess maybe it is because of the action id? May I ask how could I find the action id, or why you used 41 in the programming?

Thank you a lot!



Hi Jerry 

In order to find the transition id of the step you have to navigate to the desired workflow and then change the display from diagram to Text and then you will see a column with Transition names and their ids, something like

Screenshot 2019-01-04 at 11.06.05.png

Like hai yan Wang likes this

Hi Thanos,

but unfortunately it still didn't work. I have no idea why not :(




Can you please check your application logs for errors ?

Suggest an answer

Log in or Sign up to answer
Community showcase
Published in Marketplace Apps & Integrations

Staying organized with Jira: best practices for a better project management

Project managers know this problem: A “mountain of work” lays in front of you, and you don’t know how and where to tackle them. Different to-dos lie ahead, but just one task after the other can be ha...

274 views 2 1
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