Forums

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

Close all subtasks during a transition

Kyle Ortiz
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
May 4, 2014

Can someone help me? Thanks

2 answers

1 accepted

1 vote
Answer accepted
Fabio Racobaldo _Herzum_
Community Champion
May 4, 2014

Hello Kyle,

you could specify the following script into your transition:

import java.util.Collection;

import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.jira.issue.Issue;
import com.atlassian.jira.issue.MutableIssue;
import com.atlassian.jira.issue.status.Status;
import com.atlassian.jira.workflow.JiraWorkflow;
import com.atlassian.jira.workflow.WorkflowManager;
	
WorkflowManager workflowManager = ComponentAccessor.getWorkflowManager();
Issue issue = issue;
		
Collection<Issue> subtasks = issue.getSubTaskObjects();
for(Issue sub : subtasks){
	JiraWorkflow workflow = workflowManager.getWorkflow(sub);
	Collection<Status> statuses = workflow.getLinkedStatusObjects();
	Status destStatus = null;
	for(Status status : statuses){
		if(status.getName().equalsIgnoreCase("YOUR FINAL STATUS HERE")){
			destStatus = status;
			break;
		}
	}
	workflowManager.migrateIssueToWorkflow((MutableIssue)sub, workflow, destStatus);
}

Please, specify your final status first.

Hope this helps,

Fabio

0 votes
Kyle Ortiz
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
May 4, 2014

I did some changes on the provided script and it works well. thanks so much Fabio

Suggest an answer

Log in or Sign up to answer