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

[ScriptRunner] Validation issues in Epic are close

Hello guys!

I'm trying to create a wf validation to verify all the issues in Epic are closed, using scriptrunner validation.


This is my script

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.issue.fields.CustomField
import com.atlassian.jira.component.ComponentAccessor

MutableIssue epicLink = issue.getCustomFieldValue(customFieldManager.getCustomFieldObjectByName("Epic Link")) as MutableIssue;
IssueLinkManager issueLinkManager = ComponentManager.getInstance().getIssueLinkManager();

def Issue = getIssuesInEpic(epicLink)

if ({
!issue.get("Epic Link") || issue.get("Epic Link").getAsString("status") in ["Done","Cancel"]

return true

else return false


But, for some reason, isn't work T_T

Someone can help me?

1 answer

0 votes

There are several issues with this script (or you didn't give us all of it)... it might be easier to start over.

What's the trigger here? Are we talking about the workflow transition on the Epic itself? Or transition on all the issues in the epic?

If it's the transition in the epic (e.g. prevent closing the epic if the issue in the epic are open), you'll be better off use the "epicLinkManager"

Something like this:

import com.onresolve.scriptrunner.runner.customisers.JiraAgileBean
import com.onresolve.scriptrunner.runner.customisers.WithPlugin
import com.atlassian.greenhopper.manager.issuelink.EpicLinkManager
EpicLinkManager epicLinkManager
//issue should be the epic issue that called the validator
epicLinkManager.getIssuesInEpic(issue).any{!( in ['Done', 'Cancel'])}


If the trigger is one of the issues in the epic, then you must first find the epic issue.

Your script had some elements of that, but I think the epicLinkManager is more succinct:

def epic = epicLinkManager.getEpic(issue).get()
def issuesInEpic = epicLinkManager.getIssuesInEpic(epic)

Compared to:

def epicLinkCf = ComponentAccessor.customFieldManager.getCustomFieldObjectByName("Epic Link")
def epic = issue.getCustomFieldValue(epicLinkCf)
def issuesInEpic = epicLinkManager.getIssuesInEpic(epic)

Suggest an answer

Log in or Sign up to answer
Community showcase
Published in Jira Service Management

Atlympic Event: Jira Service Managemnt

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! ...

325 views 4 6
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