Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Jira Cloud - Scriptrunner Workflow Validator not working

Thies Uhlenbruch
Contributor
December 12, 2024

Hey,

I came up with the examples for the scriptrunner workflow validator to prevent an Epic to be closed if the tasks are not 'done'.

 

I used this expression but if its active I cannot close the tasks anymore. Did I do something wrong?

 

issue.isEpic && issue.stories.filter(story => story.status.name == 'Done').length == issue.stories.length

1 answer

Suggest an answer

Log in or Sign up to answer
0 votes
Bobby Bailey
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 13, 2024

Hi @Thies Uhlenbruch , 

From what you have said I assume your Tasks and Epics use the same workflow?

The first part of your expression is:

issue.isEpic

So, when you are transitioning a task, this returns false, and when the expression returns false it prevents the transition. 

We need to make it a little more detailed. The logic we want is: 

Check to see if an issue is an epic. If it isn't, return true. If it is, check to see if all stories are done. If they are, return true, otherwise return false

So, our expression becomes: 

issue.isEpic ?
    issue.stories.filter(story => story.status.name == 'Done').length == issue.stories.length :
    true

 

Could you try that and let me know how you get on?

Kind regards, 

Bobby

DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
PREMIUM
PERMISSIONS LEVEL
Product Admin
TAGS
AUG Leaders

Atlassian Community Events