How to move a parent task when a subtask is created?

Dear all,

I would like to move a parent task as soon as I create a subtask.

I did add a post function to the transition "Create" but it has no effect. It actually works when I am creating the second subtask but not on the first one...

Here is the script I applied :

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(181);
workflowTransitionUtil.validate();
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(181);
workflowTransitionUtil.validate();
workflowTransitionUtil.progress();

workflowTransitionUtil.progress();


Thank you very much!


Cyril 

1 answer

Suggest an answer

Log in or Sign up to answer
Atlassian Community Anniversary

Happy Anniversary, Atlassian Community!

This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.

Read more
Community showcase
Bridget Sauer
Published 12 hours ago in Marketplace Apps

Calling all developers––You're invited to Atlas Camp 2018

 Atlas Camp   is our developer event which will take place in Barcelona, Spain  from the 6th -7th of   September . This is a great opportunity to meet other developers and get n...

37 views 0 3
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