Hi guys, how are you doing.
I know this can be made using a condition, but, I'd like to do it using validator so a warning message can be shown.
That being said, here it goes:
I want to allow the issue transition only if the subtasks from that issue are all resolved or in a certain status.
How I'm trying to achieve this?
Workflow Validator > Script Runner Script
This is the Script:
def allSubtasks = get("/rest/api/2/search")
.queryString("jql", "parent=${issue.key}")
.asObject(Map)
.body
.issues as List<Map>
def allowClose = true
def subResolution = allSubtasks?.fields?.resolution
subResolution.each{ sub->
if (!sub){
allowClose = false
}
}
return allowClose
Running this code (with some customizations, to get issue) on the Script Console, it returns correctly true, when all subtasks are with a resolution, and false when not.
But, when I add it to the Validator, seems to be always false, as it not allow me to perform the transition.