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

Next challenges

Recent achievements

  • Global
  • Personal


  • Give kudos
  • Received
  • Given


  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

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 Close an Epic when all issues in Epic are closed using Scriptrunner

Hi Guys,

I need some help to close my Epic when all issues in Epic are closed, I followed this documentation,

The Scriptrunner shows the aren't errors in my code, but this post function in Stories can't work properly.

Also I did three changes.

final String actionName = "Closed" I changed to final String actionName = "Done"

final String issueLinkName = "Epic-Story Link" I changed to final String issueLinkName = "Epic Link"

*.destinationObject?.findAll { != "Complete" } I changed to *.destinationObject?.findAll { != "Done" }

Someone used this documentation and worked right?

Also I tried with Done, DONE, done, Epic Name, Epic Link and Issues in Epic


Can someone help me?




2 answers

1 accepted

Here the final code, this worked for me.


import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.workflow.TransitionOptions

// the name of the action you want to move the issue to
final String actionName = "Done"

// the name of the issue link
final String issueLinkName = "Epic-Story Link"


def issueLinkManager = ComponentAccessor.issueLinkManager

def epicIssue = issueLinkManager.getInwardLinks( { == issueLinkName }?.sourceObject
if (!epicIssue) {
def workflow = ComponentAccessor.workflowManager.getWorkflow(epicIssue)
def actionId = workflow.allActions.findByName(actionName)?.id

// Find all the linked - with the "Epic-Story Link" link - issues that their status is not completed
def linkedIssues = issueLinkManager
.findAll { == issueLinkName }
*.destinationObject?.findAll { != "Complete" }

// If there are still open linked issues (except the one in transition) - then do nothing
if (linkedIssues - issue) {

def issueService = ComponentAccessor.issueService
def issueInputParameters = issueService.newIssueInputParameters()

issueInputParameters.setComment("This Epic closed automatically because all the issues in this Epic are closed.")

def transitionOptions = new TransitionOptions.Builder()

def loggedInUser = ComponentAccessor.jiraAuthenticationContext.loggedInUser
def transitionValidationResult = issueService.validateTransition(loggedInUser,, actionId, issueInputParameters, transitionOptions)
assert transitionValidationResult.isValid() : transitionValidationResult.errorCollection

def result = issueService.transition(loggedInUser, transitionValidationResult)
assert result.isValid() : result.errorCollection

Can you explain the reasons for your changes ? I have the impression that you changed things without really knowing what you are changing and what the impact is ?

I changed to final String actionName = "Done" : your epic workflow action to "close" the Epic is called like this ?

I changed to final String issueLinkName = "Epic Link" : I think "Epic Link" is the name of a custom field of issues in epics, but is not link name ? Why do you change this ???

I changed to *.destinationObject?.findAll { != "Done" } : I think "Done" is not a valid Jira status category ! Why do you change this ?

Hi  @Marc Minten _EVS_ 

Done its my last transition and work flow status.

About "Epic Link" you are right, it's the name of field link, but the link name in Jira is "Issues in Epic" also I tried this name and doesn't work. I did changes trying to catch the rigth name of link and the name showed in script can't work.

Done it's the last statuscategory in Jira.

If I just copy this code, can't work properly here, then I did the changes according with my work flow.

Suggest an answer

Log in or Sign up to answer

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