How to implement auto transition between parent and sub task?
The workflow of parent issue has a tranistion called planning : define problem --> planned
And worflow steps before planned are : Open --> define problem --> planned
If the parent issue go through this transition,
I want the subtask (all issues linke to the parent issue) tranfer from open --> planned , and define problem --> planned.
How to achieve this?
P.S. Status "define problem" and "planned" are not jira-default status.
Thanks.
Community moderators have prevented the ability to post new answers.
Not a very good solution, but it works:
Use a custom event listener to achieve parent's trigger on subtask transition.
1. Add a custem event. (Say, eventId = "99999" You can look it up from jiraeventtype table.)
2. Set post-function of parent's transition to fire the custom event added at step 1.
3. Add custom event listener.
import java.util.Collection;
import com.atlassian.jira.ComponentManager;
import com.atlassian.jira.config.SubTaskManager;
import com.atlassian.jira.event.issue.AbstractIssueEventListener;
import com.atlassian.jira.event.issue.IssueEvent;
import com.atlassian.jira.issue.Issue;
import com.atlassian.jira.issue.MutableIssue;
import com.atlassian.jira.issue.issuetype.IssueType;
import com.atlassian.jira.util.JiraUtils;
import com.atlassian.jira.workflow.WorkflowTransitionUtil;
import com.atlassian.jira.workflow.WorkflowTransitionUtilImpl;
public class TransitionListener extends AbstractIssueEventListener {
@Override
public void customEvent(IssueEvent event) { // listen all custom event
Issue parent = event.getIssue();
String eventId = Long.toString(event.getEventTypeId());
if ("99999".equals(eventId)) { // listen to specific custom event added at step 1
try {
WorkflowTransitionUtil workflowTransitionUtil = (WorkflowTransitionUtil) JiraUtils.loadComponent(WorkflowTransitionUtilImpl.class);
SubTaskManager subTaskManager = ComponentManager.getInstance().getSubTaskManager();
Collection<MutableIssue> subTasks = subTaskManager.getSubTaskObjects(parent);
for (MutableIssue subTask : subTasks) {
workflowTransitionUtil.setIssue(subTask);
workflowTransitionUtil.setAction(11); // subtask's action id --Trigger subTask's transition
workflowTransitionUtil.validate();
workflowTransitionUtil.progress();
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
}
JIRA Workflow Toolbox plugin can be used to make any linked issues, subtasks, JQL selected issues and parent issue progress through its workflow. You can check how to do it at documentation site:
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
https://marketplace.atlassian.com/plugins/com.innovalog.jmwe.jira-misc-workflow-extensions
I found JIRA-MISC-WORKFLOW-EXTENSIONS's "Transition Parent Issue" can achieve part of my requirement. However, it only permits child's trigger on parent transition, not the other way around.
Put it another way, how can we achieve dual transition trigger between parent and sub-task?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Or you can use Script Runner(https://marketplace.atlassian.com/plugins/com.onresolve.jira.groovy.groovyrunner) by writing your own script and adding it as post function
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Can you be more specific of what related api on transition triggering is ? Thanks.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
here is the post function groovy script. Change transition id and link type if you need. This is for linked issues you can change it to subtask.
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.workflow.WorkflowTransitionUtil; import com.atlassian.jira.workflow.WorkflowTransitionUtilImpl; import com.atlassian.jira.util.JiraUtils; import com.atlassian.jira.issue.link.IssueLink; import com.atlassian.jira.issue.Issue import com.atlassian.jira.issue.IssueFieldConstants import com.atlassian.jira.issue.index.IssueIndexManager import com.atlassian.jira.util.BuildUtils import com.atlassian.jira.issue.IssueManager import com.atlassian.jira.util.ImportUtils IssueIndexManager indexManager = ComponentManager.getInstance().getIndexManager() def Category log = Category.getInstance("com.onresolve.jira.groovy.PostFunction") log.setLevel(org.apache.log4j.Level.DEBUG) String currentUser = ((WorkflowContext) transientVars.get("context")).getCaller(); WorkflowTransitionUtil workflowTransitionUtil = ( WorkflowTransitionUtil)JiraUtils.loadComponent( WorkflowTransitionUtilImpl.class ); linkType = "duplicates" linkMgr = ComponentManager.getInstance().getIssueLinkManager() for (IssueLink link in linkMgr.getInwardLinks(issue.id)) {
if (linkType == link.issueLinkType.name) {
Issue dup = link.sourceObject;
workflowTransitionUtil.setIssue(dup)
workflowTransitionUtil.setUsername(currentUser)
workflowTransitionUtil.setAction (111)
workflowTransitionUtil.validate();
workflowTransitionUtil.progress(); boolean wasIndexing = ImportUtils.isIndexIssues(); ImportUtils.setIndexIssues(true); if ((BuildUtils.getCurrentBuildNumber() as Long) < 614) {
ManagerFactory.getCacheManager().flush(com.atlassian.jira.issue.cache.CacheManager.ISSUE_CACHE, issue)
} indexManager.reIndex(issue); indexManager.reIndex(dup); ImportUtils.setIndexIssues(wasIndexing); }
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Rowens,
You can do that using the JJupin pulgin. Here is a tutorial http://confluence.kepler-rominfo.com/display/TR/Autotransitioning+subtasks
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Community moderators have prevented the ability to post new answers.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.