Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Condition or Validator to check specific sub-tasks

Hi,

In our instance, a story can have various sub-tasks but will always have a 'QA Task' sub-task. I need to use ScriptRunner to block a specific transition if any sub-tasks are not closed excluding the 'QA Task' sub-task.

I referenced this first example in the documentation with some tweaks, but to no avail (it seems 'passesCondition' is not valid: https://scriptrunner.adaptavist.com/6.4.0-p5/jira/recipes/workflow/conditions/all-subtasks-resolved.html

Can anyone help with producing a simple script that will block the transition (preferably using a validator) unless all sub-tasks except QA Task are closed?

Many thanks,

Howard

 

 

2 answers

Suggest an answer

Log in or Sign up to answer
0 votes
Jia Jie
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.
Feb 02, 2021

Hi Howard, 

You can use a custom script validator to throw an InvalidInputException and block the parent issue's transition if conditions aren't meet. 

Here's the sample custom script validator when not all sub-tasks (except QA Task) of that parent issue are closed as "Done", then it will throw an exception and block the transition for that parent issue:

import com.opensymphony.workflow.InvalidInputException

def passesCondition = true
def subTasks = issue.getSubTaskObjects()
def subBoolean = issue.subTask

//If the issue is not a subtask and contains subtasks
if(!subBoolean && subTasks){
subTasks.each { //Loop each subtask of parent issue
//If the subtask is "QA Task"
if (it.issueType.name == "QA Task") {
passesCondition = true
}else{ //Else if the subtask is not "QA Task"
//If the subtask has null resolution or not a resolution "Done"
if(!it.getResolution() || it.getResolution().name != "Done"){
passesCondition = false
//Block the transition
throw new InvalidInputException("subTask","Not all substasks ($it) are closed as 'Done'!")
}else{
passesCondition = true
}
}
}
}else{
return true
}

Hope this helps!

0 votes
Jia Jie
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.
Feb 02, 2021 • edited

--

TAGS
AUG Leaders

Atlassian Community Events