Automatically Transition a Parent Issue from a Subtask in JIRA

Guest post from Peter Van de Voorde on automatically transitioning a parent issue from a subtask in JIRA. See the step by step guide.

Parent Issue from a Subtask in JIRA
Transition

A Guest Post by Peter Van de Voorde

In this post I’ll explain how you can automatically transition a Parent Issue when transitioning a subtask in JIRA.

We’ll create a custom post function using the Script Runner plugin

I’ll explain the process in a few simple steps:

  • Install the Script  Runner plugin using your JIRA Add-ons menu.
  • Create a Draft of the workflow your subtask is using.
  • Open the transition on which you want trigger the transition of the Parent.
  • Go to the Post Function Tab and click on add a post function
  • Select Script Post-Function
  • Select Custom script post-function
  • Now paste in the following code and fill in the number of the transition (marked in red in the setAction method below) you want to Parent to execute:

import com.atlassian.jira.ComponentManager;import com.atlassian.jira.issue.comments.CommentManager;import com.opensymphony.workflow.WorkflowContext;import org.apache.log4j.Category;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; log =Category.getInstance(“com.onresolve.jira.groovy.AutoCloseChildIssues”);String currentUser =((WorkflowContext) transientVars.get(“context”)).getCaller();WorkflowTransitionUtil workflowTransitionUtil =(WorkflowTransitionUtil)JiraUtils.loadComponent(WorkflowTransitionUtilImpl.class)

;MutableIssue parent = issue.getParentObject(); workflowTransitionUtil.setIssue(parent); workflowTransitionUtil.setUserkey(currentUser); workflowTransitionUtil.setAction(11); workflowTransitionUtil.validate(); workflowTransitionUtil.progress();

  • Press Add.
  • Move your new Post Function to the bottom of the post function list (behind the Re-index post function).
  • Done.

About Peter Van de Voorde

Peter is a 30-something Belgian with a passion about everything Agile. By day he’s an Atlassian Expert and ALM Consultant at RealDolmen. In the evening he’s a family man, an active member of Atlassian Answers and the Atlassian Belgian User Group, and a boardgame fanatic. To see Peter’s previous guest posts for Clearvision, see our guest posts tag. For more by Peter, visit his website: http://www.petervandevoorde.com/

Atlasssian expert resources

Visit our blog for expert news and articles from the Atlassian world. On our resources page you will find recorded webinars, white papers, podcasts, videos and more.

The Software Blog

Read our blog for articles offering best practice advice written by Atlassian experts, as well as the latest news concerning your software.

Software White Papers and Guides

Dive deep into Atlassian software with our white papers and guides on individual tools, partner products, services, and best practices, written by the experts.

Expert Webinars

All of our webinars are pre-recorded and available to watch on-demand. Enjoy everything from partner features to application demos and updates from Atlassian experts.

Subscribe to our Newsletter

Subscribe to our Newsletter