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

Allow Story in Epic transition only in a specific status of Epic

I have spent most of my day today looking for a ScriptRunner condition or validator that meets this seemingly simple requirement.

I have a requirement that a Story which belongs to an Epic can only be transitioned from 'Backlog' to 'To do status', when the Epic is in 'In Progress' status. 

I thought this kind of condition/validator script will be easy to find here or in Adaptavist library but I could not find any simple solutions. I do not want to use JMWE nor Automation to synchronise statuses. I want to block the status change on a Story until the Epic status is transitioned properly.

Any help will be greatly appreciated.

2 answers

1 accepted

1 vote
Answer accepted

That option is available with JSU and with scriptrunner



Thanks for your screenshots, especially number 2. I admit I have always overlooked that one. The investigation is getting exciting and here are my results.

I tested thorougly ScriptRunner JQL functions as described here:

My use cases with ScriptRunner functions are as follow:

1. if you use function

 issueFunction in epicsOf("status= 'In Progress'")

as a result you will find get all Epics that have stories in status 'In Progress'. It is of no use in ScriptRunner JQL query condition because it doesn't test that one specific Epic linked with a Story. I tested it as a Condition on workflow transition and it doesn't work.

2. if you use function

issueFunction in issuesInEpics("project = EXP and status = 'In Progress'")

as a result you will find all Stories that belong to Epics from project EXP but only these Epics which are in status 'In Progress'

3. and the most interesting finding, if you use function 

issueFunction in hasLinkType("Epic-Story Link")

as a result you will find all Stories AND Epic which are connected by this link type. NB. I guess this type of linking is not described in Adaptavist documentation.

Especially the 3rd one is of True/False type, so this one can be used if you want to create a ScriptRunner condition and test if Epic has any Stories inside or a Story is linked with any Epic. I tested this one as condition in Story transition and it works! In this way you can ensure that Stories are always linked with Epics otherwise cannot be processed.

Although I still have not found the solution, I am happy that I have tested all the above ScriptRunner functions.

issueFunction in issuesInEpics("status = 'IN PROGRESS'") or epic link is EMPTY

does exactly what you need (or what i understood yoou need),

An issue can transition if does not belong to any epic or if the epic it belongs to has the status 'IN PROGRESS'

Hope it helps

Yes Fran, at last with your help I found the working solution.

When I simply copied and pasted your last JQL query, this was the result:

2019-10-02 20_03_55-Window.png

But then I realized that the proper query should have quotation marks (which were missing also in the first JQL query)

So, I implemented the following solution:

issueFunction in issuesInEpics("statusCategory = 'In Progress'") AND "Epic Link" is not EMPTY

I tested it and it WORKS! Only when a story is linked with an Epic AND when it is linked with an Epic which is In Progress category status, the transition button for the Story will appear.

Great stuff! Thanks again for your help!

Note: the above reply I accidentally wrote using my other account which I never use here. Anyway - the solution works!

if you have scriptrunner there is a JQL function:

issueFunction in epicsOf("status= In Progress")

You can create a scriptrunner condition of type "Allows the transition if this query matches a JQL query"

Thank you for your reply. It is a good idea with only one but.

Are you sure that this is the scriptrunner condition? Isn't that condition that you are mentioning a part of JSU plugin and that JQL feature was only added recently in version 2.15 released in July?

I wanted to achieve the result with only ScriptRunner scripted condition, if possible. However, as I said, it is a good idea for those having JSU available.

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