Groovy Script for auto transition of Subtask which can be included in post function of parent ticket

Hi All,

If someone can help me out with a script for auto transition which can be used or included in the post function of parent ticket. So all I need to do is auto transition of Subtask with the transition of parent ticket.

Have just started working on JIRA and I am pretty much new to scripting  as well.

So any help on this would be great.


Amir Vegdani

4 answers

1 accepted

2 votes
Answer accepted

Here, I have Sub-tasks under parent story. When the parent's transition is changed, the Sub-tasks will be moved to the Closed state. This script is placed in post function of Parent's workflow transition. Specify the ResolutionId and JIRA status Id in setResolutionId and setAction respectively

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.resolution.Resolution
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.issue.IssueInputParameters
log = Category.getInstance("com.onresolve.jira.groovy.AutoCloseChildIssues")
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) 
  if( == "Sub-task")
   String status = it.getStatus().get("name").toString()
    log.debug (" " +
    CommentManager commentManager = (CommentManager) ComponentManager.getComponentInstanceOfType(CommentManager.class);
    String comment = "Moving to *new status* status as a result of the *this transition* action being applied to the parent.";
    commentManager.create(it, currentUser, comment, true);

Please let me know your results. smile

What's your question? Does this relate to the original question? If not please create a new one.

@Jamie Echlin [Adaptavist] Nope, this not a question. I saw this while randomly navigating here. So I thought of providing the solution to the above mentioned question, eventhough it is an old one. This is an answer!

Is it on all actions or just one, or particular actions?

Hi Jamie, I need to do this on a particular transition only. For e.g. we raise issue on JIRA, once we get projects. These projects might start on a future date. So on that particular date when I move my parent ticket to In Progress from Awaiting Project Start, I want all the sub task to move into In Progress from Awaiting Project Start.

I too need this to be implemented in the post function of a parent issue transition. Requirement: clicking on the "start progress" button in the parent task should automatically set the status of all underlying sub tasks to "In Progress".

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Mar 13, 2019 in Marketplace Apps

Marketplace Spotlight: Marketing apps for Confluence to keep your teams working on the same page


275 views 0 7
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