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

2 votes
Accepted answer

See my answer here.

Thanks Henning. This works a treat.

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Jan 08, 2019 in Jira

How to Jira for designers

I’m a designer on the Jira team. For a long time, I’ve fielded questions from other designers about how they should be using Jira Software with their design team. I’ve also heard feedback from other ...

955 views 3 9
Read article

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