Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

parent issue status not updating when all subtasks are moved to completed

gagan m s May 14, 2019

Hello Team,

im using the below code in post function of a transition to check if all the subtasks are in "Completed" status and to move the parent to "Completed".

however the code is not working .

can anyone please help me on this?

import com.opensymphony.workflow.WorkflowContext;
import com.atlassian.jira.config.SubTaskManager;
import com.atlassian.jira.workflow.WorkflowTransitionUtil;
import com.atlassian.jira.workflow.WorkflowTransitionUtilImpl;
import com.atlassian.jira.util.JiraUtils;
import com.atlassian.jira.issue.MutableIssue;
import com.atlassian.jira.component.ComponentAccessor

String currentUser = ((WorkflowContext) transientVars.get("context")).getCaller()
WorkflowTransitionUtil workflowTransitionUtil = (WorkflowTransitionUtil) JiraUtils.loadComponent(WorkflowTransitionUtilImpl.class)
MutableIssue parent = issue.getParentObject() as MutableIssue
if(parent){
passesCondition = true

def subTasks = parent.getSubTaskObjects()
subTasks.each{if(!(it.getStatus().name=="Completed"))
{
passesCondition = false
}
}

if (passesCondition) {
workflowTransitionUtil.setIssue(parent)
workflowTransitionUtil.setUserkey(currentUser)
workflowTransitionUtil.setAction(61)
if (workflowTransitionUtil.validate()) {
workflowTransitionUtil.progress()
}
}
}

1 answer

0 votes
Marc Minten (EVS)
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 15, 2019

...add logging to your script and find out what is happening ?

Where did you put this Post Function (before or after what other Post Functions ?)

Suggest an answer

Log in or Sign up to answer