Prevent transition if issue has sub-tasks / stories, and the sub-tasks / stories are not in-progress

Steve Beauchamp January 16, 2019

Hi,

I am looking for a way to:

  1. Prevent a Story from being transitioned from To-Do to In Progress manually if it has Sub-Tasks (this happens automatically with a post-function on the In Progress transition, which transitions the Sub-Task's parent issue)
  2. Allow a Story to be transitioned manually from To-Do to In Progress if it has no Sub-Tasks

I have looked through the available conditions in my JIRA instance, and can't find anything out of the box that will help me, so I think I will have to script this in Groovy. 

Any ideas on the best way to approach this?


**UPDATE**

The original question didn't mention that I was looking for a way to handle this transition for Epics and Stories. 

@David Fischer provided a solution that works for both relationships, in the form of a workflow condition:

!issue.stories && !issues.subtasks

 

2 answers

1 accepted

1 vote
Answer accepted
David Fischer
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
January 17, 2019

For the first requirement, you shouldn't use a Validator but a Condition, because otherwise the post-function that automatically triggers the transition will make the user-triggered transition (the one on which the post-function resides) fail as well. This is a long standing Jira bug. 

For both requirements, you can use the JMWE app's "linked issues" condition and validator without any coding required. 

Steve Beauchamp January 17, 2019

Hey @David Fischer

Thanks for your reply. The only JMWE linked issues condition I can find requires ALL Sub-Tasks to be in the specified status(es) before the transition can occur. This means that when the Story won't enter an "In Progress" state until all of the Sub-Tasks are in-progress.

What I'm hoping to do is:

If the Parent has Children:
Hide the transition from the user, and have it triggered by a post-function when one of the children enters the "In Progress" state. 

If the Parent does not have Children:
Allow the user to trigger the transition manually. 

David Fischer
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
January 17, 2019

You're right, your requirement is better served with a Scripted (Groovy) Condition with the following code:

!issue.get("subtasks")

However, this will also hide the transition from automated transitions, such as the Transition Parent Issue post-function you're probably using, so you'll also need to use the "Skip workflow conditions" option of that post-function.

Steve Beauchamp January 17, 2019

Hi again,

I've tried what you suggested, but it's not really doing what I want it to do, as I want the script to work for all parent/children relationships (e.g. Epics that have Stories & Stories that have Sub-tasks).

The code I'm trying to play around with is this - which isn't working, for the same reason - is as follows:


if (issue.parent != null) false
if (issue.subtasks != null) false
else true

Also, the Transition Parent Issue post-function doesn't have a "skip workflow conditions" option. Perhaps that's in a recent version that I haven't upgraded to yet? 

David Fischer
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
January 17, 2019

You didn’t mention earlier that you want this to apply to Epics and Stories. This relationship is completely different from the issue/subtask relationship in Jira. In Jira, “parent” really only applies to subtasks. 

For example, the transition parent issue post-function will only apply to the parent/subtasks relationship. To transition the parent Epic of a Story, you need to use the Transition Linked Issues post-function with the “belongs to Epic” link type. 

Likewise, if you want to hide the Start Progress transition on an Epic when it has Stories, the code will be different:

!issue.stories

Finally, the option to ignore conditions and validators was added in JMWE 5.6.0. 

Steve Beauchamp January 18, 2019

Hi @David Fischer,

This works perfectly, thanks!

My apologies for not specifying that this should apply to both Epics & Stories. I will mark this as 'solved' and update the description of my original question for anyone else that is looking to do the same thing. 


Thanks for the help! 

2 votes
Deleted user January 16, 2019

Hi @Steve Beauchamp,

 

You may consider any of the following two options :

simplescript.png

 

Hope this helps.

 

Thanks,

Swathi

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events