Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Transition Parent When subtask is closed

Hi All,

This question has been asked multiple time on the forum and i referred below links to accomplish this, but still not successful

https://community.atlassian.com/t5/Jira-questions/Transition-parent-to-close-when-sub-tasks-are-closed-is-not/qaq-p/88697

https://answers.atlassian.com/questions/75677/automatic-transition-on-parent-issue-when-all-sub-tasks-are-closed

I have a Parent issue workflow:

P1->P2->P3

Parent issue is currently in P2 stage

Subtask Issue workflow:

S1->S2->S3

Subtask status is S2

When Ssubtask moves from S2 to S3 , parent should move from P2 to P3.

I am using script runner plugin and added the post function in the subtask workflow, but still not able to change the status of the parent issue.

Please help

1 answer

1 accepted

1 vote
Answer accepted
Nir Haimov Community Leader Aug 24, 2018

This script will transition your issue.

Just change "211" from my code to the action you want in your post function

import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.jira.util.JiraUtils;
import com.atlassian.jira.workflow.WorkflowTransitionUtil;
import com.atlassian.jira.workflow.WorkflowTransitionUtilImpl;
import com.atlassian.jira.issue.MutableIssue;
import com.atlassian.jira.util.ErrorCollection;

def currentUser = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
WorkflowTransitionUtil workflowTransitionUtil = JiraUtils.loadComponent(WorkflowTransitionUtilImpl.class);
workflowTransitionUtil.setIssue((MutableIssue)issue);
workflowTransitionUtil.setUserkey(currentUser.getKey());
workflowTransitionUtil.setAction(211);
if (workflowTransitionUtil.validate().getErrorMessages().size() == 0) {
workflowTransitionUtil.progress();
}

Hi @Nir Haimov thanks for the reply.

But I want to change parent status based on change in subtask status. This script might need to be pasted in subtask post function and does not work if I use P3 instead of 211

Nir Haimov Community Leader Aug 24, 2018

Hi @Hemanshu Sood,

Use this as post-function in your sub-task.

change this line:

workflowTransitionUtil.setIssue((MutableIssue)issue);

to:

workflowTransitionUtil.setIssue((MutableIssue)issue.getParentObject());

 Yes, 211 is your P3 (but actionId and not statusId), and it will work :)

Wow, this works @Nir Haimov. Thanks 

Like Joseph Ramirez likes this

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Posted in Jira Core

How to manage many similar workflows?

I have multiple projects that use variations of the same base workflow. The variations depend on the requirements of the project or issue type. The variations mostly come in the form of new statuses ...

3,873 views 11 5
Join discussion

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you