scriptrunner validation if subtaks all resolved

I have scriptrunner in Jira 6.2 and a Workflow with several steps and subtasks. In each phase of the workflow, I need a validation if the previous subtasks (2-5 per phase) are closed or resolved before moving on to the next step. The Next step button should always be visible, but an exception shall be thrown and the transition stopped.

I tried using the example condition “All sub-tasks must be resolved” in simple scripted validator, but i guess this wont work out. I cannot use this script on validation page, or?

Thanks for any hints.

3 answers

1 accepted

This widget could not be displayed.

now i finally found a way to check and validate against open subtasks:

import com.atlassian.jira.ComponentManager
import com.atlassian.jira.issue.Issue
import org.apache.log4j.Category
import com.atlassian.jira.config.SubTaskManager

Collection subTasks = issue.getSubTasks()

if (issue.getSubTasks().status.contains ("1")){
            return false     	
}
else return true

the status "open" alway has the value 1

 

This widget could not be displayed.

Hey Alex, 

if it doesn't work probably your workflow doesn't resolve issues and just set them in the next status (closed, done etc).  
when this is the case set a condition in your sub-workflow that the issue must have a resolution to bet closed and set a screen with resolution in this transition as well.
Hope this is your problem- because it's easy to fix. laugh 

Have a nice day and provide feedback if this was your problem. 

@Alex Alex I think you missunderstood the function. Yes you can set it as a validator / condition - BUT it doesn't check if your issues are closed. Maybe closed isn't the last status in your workflow so it's not that good hint. It just check if tickets are resolved - not the status. Resolved means that the issue got a resolution (field). This can be fixed, won't fix, done, can't reproduce etc. And this is what the condition checks - resolution is Not empty.

sorry for the wrong mention - didn't get the other Alex :(

Hi Simon, thank you for detailed explanation. i now understand the function underneath. I will have a deeper look into that, until i find a solution for my notification-validation problem.

Hi Simon, thank you for your quick answer! i'm not quite sure if i understand you correctly. there is an exapmle in script-runner plugin when creating a condition: all subtasks must be closed.

that is exactly what i need, but also with a workflow-warning poping up. And this warning, i assume, is only possible in validators-section when configure a transition.

therefor i'd like to create my own script in add parameters to validator -> simple scripted validator -> condition:

import com.atlassian.jira.issue.Issue
import org.apache.log4j.Category
import com.opensymphony.workflow.InvalidInputException

SubTaskManager subTaskManager = ComponentManager.getInstance().getSubTaskManager();
Collection subTasks = issue.getSubTasks()
if (subTaskManager.subTasksEnabled && !subTasks.empty) {
    subTasks.each {
        if (!(it.resolution > 0))
            passesCondition = false
    }
}

So when one of my subtasks is at status open, throw exception - else proceed.

sorry if this is completly wrong thinking - i'm newby to Jira-world

ok now i set my subtask workflow to automatically set the resolution to completed when closing. so for my validation, the code above should return a false statement and the exception sall be thrown if one or more resolutions aren't set. but somehow it always return true. i cannot access log or have any option for debugging.

This widget could not be displayed.

so, nobody used some kind of notifications? is there any other possibility to warn a user if subtasks aren't closed before proceeding?

 

Can't mention you - cause to your username :( Wrote an explanation above

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted Tuesday in Jira

What modern development practices are at the heart of how your team delivers software?

Hey Community mates! Claire here from the Software Product Marketing team. We all know software development changes rapidly, and it's often tough to keep up. But from our research, we've found the h...

226 views 1 3
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you