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

Accepted Answer
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 Sign up to answer
Community showcase
Posted Sep 18, 2018 in Jira

What modern development practices are at the heart of how your team delivers software?

Hey Community mates! Claire here from the Software Product Marketing team. We all know software development changes rapidly, and it's often tough to keep up. But from our research, we've found the h...

24,837 views 2 7
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