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.
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
so, nobody used some kind of notifications? is there any other possibility to warn a user if subtasks aren't closed before proceeding?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Can't mention you - cause to your username :( Wrote an explanation above
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
Have a nice day and provide feedback if this was your problem.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
sorry for the wrong mention - didn't get the other Alex :(
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.