I am trying to setup a fast-track transition using the Script Runner plugin. It appears, however, that I cannot access nor modify variables declared before the loops inside the loops. Similarly, I cannot access variables from inside the loop outside of it. Does anyone have any suggestions?
My current code:
subtasksclosed = true parent = issue if(issue.isSubTask()){ parent = issue.getParentObject() Outer: for (subtask in parent.getSubTaskObjects()){ if (subtask.statusObject.name != "Closed"){ subtasksclosed = false break Outer } subtasksclosed = true } } else if(issue.subTasks.size > 0) { Outer2: for (subtask in issue.getSubTaskObjects()){ if (subtask.statusObject.name != "Closed"){ subtasksclosed = false break Outer2 } } } subtasksclosed == true && parent.statusObject.id == "10020"
Maybe you could try this code, so you don't have to access variables from "the other side":
parent = issue if(issue.isSubTask()){ parent = issue.getParentObject() } subtasksclosed = parent.subTaskObjects.any{it.statusObject.name != "Closed"} subtasksclosed && parent.statusObject.id == "10020"
Henning
Yes, write it using any(<closure>). I don't see any obvious reason why the original code is not working, but if you do it like Henning suggests it will be a lot more succinct and more obvious if there is a bug.
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.
Any error messages in the log?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I think you should try to add a lot of
log.error issue.dump()
...
log.error parent.dump()
...
lines to your source to get the point where the scripts don't behave like expected.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Interestingly, if I run this through the built in "Condition Tester" in the plugin, it works fine.
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.