Using Post function script to Transition Sub-Tasks

Hi All, I am new to groovy so need some advice on the post function scripts.

I would like to use a post script to transition all Sub-taks of the parent.

I found this script to close sub-tasks

The question is, apart from the action ID, what else do I need to change to make it specific to my JIRA project?


String currentUser = ((WorkflowContext) transientVars.get("context"))

Do I need to change "Context" to something more specific


Do I need to change "it" to the issuetype of the subtask?

Also, Do I need to call a package (e.g. package com.onresolve.jira.groovy.canned.CannedScript) before running the script?

I am using the Post Function "Script Post-Function" -> Script file, using the absoulte file path.

I'm running JIRA v5.2.4 with Script Runner 2.1.12

This is what I have in the file, but at the moment it is not working....

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;

log = Category.getInstance("com.onresolve.jira.groovy.AutoTransitionChildIssues")

String currentUser = ((WorkflowContext) transientVars.get("context")).getCaller();
WorkflowTransitionUtil workflowTransitionUtil = ( WorkflowTransitionUtil ) JiraUtils.loadComponent( WorkflowTransitionUtilImpl.class );

SubTaskManager subTaskManager = ComponentManager.getInstance().getSubTaskManager();
Collection subTasks = issue.getSubTaskObjects()
if (subTaskManager.subTasksEnabled && !subTasks.empty) {
subTasks.each {
log.debug (" " +
workflowTransitionUtil.setAction (101) // Transition ID e.g. 5 == RESOLVE ISSUE

// Add a comment so people have a clue why the child has been closed
CommentManager commentManager = (CommentManager) ComponentManager.getComponentInstanceOfType(CommentManager.class);
String comment = "*Assign Resolution* set as a result of the *Assign to Me* action being applied to the parent.";
commentManager.create(it, currentUser, comment, true);

// validate and transition issue

Any help would be appreciated.



1 answer

1 accepted

1 vote
Henning Tietgens Community Champion Mar 03, 2014

See my answer here.

Thanks Henning. This works a treat.

Suggest an answer

Log in or Join to answer
Community showcase
Sarah Schuster
Posted Jan 29, 2018 in Jira

What are common themes you've seen across successful & failed Jira Software implementations?

Hey everyone! My name is Sarah Schuster, and I'm a Customer Success Manager in Atlassian specializing in Jira Software Cloud. Over the next few weeks I will be posting discussion topics (8 total) to ...

3,335 views 14 20
Join discussion

Atlassian User Groups

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

Find a group

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

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot