The Atlassian Community Forums are currently in read-only mode. We will be relaunching on a new platform on September 22 (read more here). We apologize for the extended downtime. For concerns or questions, please email communitymanagers@atlassian.com. See you on the other side, on the new Atlassian Community Forums! :)

×

Forums

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

Transition Parent When subtask is closed

Hemanshu Sood
Contributor
August 24, 2018

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

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

1 vote
Answer accepted
Nir Haimov
Community Champion
August 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();
}
Hemanshu Sood
Contributor
August 24, 2018

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 Champion
August 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 :)

Hemanshu Sood
Contributor
August 24, 2018

Wow, this works @Nir Haimov. Thanks 

Like • Joseph Ramirez likes this