Prevent Issue -> Done if there are sub-tasks open. Scriptrunner as a workflow transition validator

Justin PB Tran
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
April 9, 2024

Hello,

I'd like some assistance with creating a script so that I can use Scriptrunner as a 'validator' within a workflow transition to 'Done', where it parses the issue's subtasks to check if all of them are in a 'Done' state. 

I'd also like to return an error message saying "Please ensure sub-tasks are complete before transitioning.", which I know can be done in the Validator side.

I am currently using the 'Condition' for sub-task state which currently works as a v1 fix, but we'd like to have that error message which seems to be reserved for 'Validators'.

I don't have much scripting experience, and could use some help with this please if it's possible!

Thank you,

Justin

2 answers

0 votes
Matt Parks
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
April 9, 2024

You can't provide an error message with a Condition because the Condition determines whether the transition can be executed at all. If you don't meet all of the conditions, the transition is not available.

An example of a script that would prevent you from executing the transition if any sub-tasks do not have a status of Closed would look like this (note that this is for Data Center, not Cloud)

2024-04-09_17-22-16.png

 

0 votes
Maciej Dudziak _Forgappify_
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.
April 9, 2024

If you don't have scripting experience and prefer wizzard-like validator/condition, take a look at Linked Issues Validator which is part of the free Workflow Building Blocks for Jira app.

1. Add validator to the transition

2. Set Relation to Sub-tasks

3. In Status category: select Done

 

community_subtasks_done_validator.png

This validator comes with a default validation message, wich in this case will be:
"If there are sub-tasks. All of them must be in the status category: 'Done'."

If that message is not sufficient for your needs, copy the generated expression and use the Jira Expression Validator (also part of Workflow Building Blocks for Jira). Paste the expression and provide your validation message.

Full disclosure: I am from Forgappify, the vendor of the app.

I would appreciate it if you could give it a try.

Cheers

 

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
PREMIUM
TAGS
AUG Leaders

Atlassian Community Events