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.
Thanks
Amir Vegdani
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) { subTasks.each { if(it.issueTypeObject.name == "Sub-task") { String status = it.getStatus().get("name").toString() if(!(status.equals("Closed"))) { it.setResolutionId("7") log.debug ("issue.statusObject.name: " + issue.statusObject.name) workflowTransitionUtil.setIssue(it); workflowTransitionUtil.setUsername(currentUser); workflowTransitionUtil.setAction(161) 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); workflowTransitionUtil.validate(); workflowTransitionUtil.progress(); } } } }
Please let me know your results.
What's your question? Does this relate to the original question? If not please create a new one.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@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!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
oh ok cool, thanks!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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".
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Is it on all actions or just one, or particular actions?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.