I am attempting to resolve a very simple issue – I want to have a parent task's status in our workflow change to Resolved, when (and only when) all associated sub-tasks have been moved to Resolved. To me, this seems like very basic functionality, but I am not a coder. Our JIRA instance is Cloud / Ondemand, so our plugin options are limited, but I have been working with JIRA Misc Workflow Extensions.
I have looked through the documentation here, and experimented with changing the properties in Workflow Transitions. Several posts refer to using Conditions or Validators to determine the criteria for a parent task transitioning from one state to another. I have had some success using Transition Parent Issue in Post Functions – setting a status transition to be "triggered on the issue's parent issue."
However, I have found that when a task tries to transition a parent task to a state it's already in, I get an error. For example, let's say I create a task with 2 sub-tasks. I move one sub-task from To Do to In Progress. The parent task is correspondingly set to In Progress (good so far). But when I try to move the second task from To Do to In Progress, the parent task is already set to In Progress. Here is the error message:
image2015-9-4 17:30:35.png
For the life of me, I cannot figure out how to use Workflow Transitions to limit a transition based on criteria (such as excluding an interaction if the parent is already set to a certain status). I am instead attempting to use a Groovy script – there is an option in Post Functions for a Conditional Execution "only if the Groovy expression returns true." This simple code has been effective for the above interaction:
if(parentIssue.get("status").getName()
== "To Do" || parentIssue.get("status").getName() ==
"Reopened"){
return true;
} else {
return false;
}
Again, I am not a developer and have borrowed code from other documentation on this site. However, I am still unable to address my main problem with subtasks – changing a parent task's status to Resolved if ALL subtasks are marked Resolved (again, using Groovy for a Conditional Execution). This is the logic I have in mind:
If [there are NO other sub-tasks that are NOT marked Resolved], return True
Else, return False
Our workflow is very simple: To Do / Reopened > In Progress > Resolved > Closed. Here is the code I have cobbled together:
Collection<Issue> subTaskList = subTaskManager.getSubTaskObjects(issue);
Resolution resolutionObj=issue.getResolutionObject();
if(resolutionObj != null && resolutionObj.getName().equals("Resolved")){
boolean anysubtaskNotclosed = false;
for(Issue subTaskObj : subTaskList){
Status subStatus = subTaskObj.getStatusObject();
if(subStatus.getName().equals("Resolved")==false && subStatus.getName().equals("Closed")==false){
anysubtaskNotclosed = true;
break;
}
}
if(anysubtaskNotclosed = true){
return false;
} else {
return true;
}
}
I believe the issue is likely something in the syntax I'm not catching here. Please advise.