Hello,
I wonder how can I close subtasks, when parent issue is closed. I have found something like post-functions example codes (here).
I'm using the same code from the example above for default workflow (just testing ;) ) and instead of closed sub-tasks I've got sth like this:
groovy.lang.MissingPropertyException: No such property: a for class: Script2
I must admit that I am not best in 'grooving'- could anyone help me? I would really appreciate.
Hi Jan,
Your code seems to be fine, only thing that might be going wrong is the transition Id
workflowTransitionUtil.setAction (
5
)
Make sure you use the transition Id from your workflow instead of the one given in the docs
Hey,
Thanks a lot for your answer.
Silviu,
unfortunately JJupin isn't for free and this may be a little problem to use it.
Tarun,
What is the best way to check my transition ID? In my database, I can see that (like in the code above): 5 == RESOLVE ISSUE; 10023 == Zakonczony
"Zakonczony" with Id == 10023 is my target action.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
In the code above- 5 is the transiton ID which will take the issue to current status to resolve status thus you need to know your transition ID of the transtion that you wish to execute which can be global transition( from all statues to closed) or it can be a single transtion( form a particular status to closed)
Just open your project workflow through the admin rights to access the workflow section of the jira instance
yourjiraInstance/admin/workflows/ListWorkflows.jspa
Now in the workflow you can clearly se the transition id next to transition name.
example
StartProgress(4)
Move to done(20)
Move to close (40)
what you see in the paranthesis is the transition id.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
You can do it quite easily with JJupin and a short SIL Script post function:
string sk; if (%key%.status == "Closed") { for (sk in subtasks(key)) { autotransition("Close Issue", sk); } }
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Here you are:
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.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 { log.debug ("issue.statusObject.name: " + issue.statusObject.name) workflowTransitionUtil.setIssue(it); workflowTransitionUtil.setUsername(currentUser); workflowTransitionUtil.setAction (5) // 5 == RESOLVE ISSUE; 10023 - zakonczony // Add a comment so people have a clue why the child has been closed // CommentManager commentManager = (CommentManager) ComponentManager.getComponentInstanceOfType(CommentManager.class); // String comment = "*Resolving* as a result of the *Resolve* action being applied to the parent."; // commentManager.create(it, currentUser, comment, true); // validate and transition issue workflowTransitionUtil.validate(); workflowTransitionUtil.progress(); } }
"workflowTransitionUtil.setAction (
5
)" <-- Here is the scrap I should change If I'd like to use another action, right? ( id == 10023 for my workflow)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You can do it quite easily with JJupin and a short SIL Script Post Function:
string sk; if (%key%.status == "Closed") { for (sk in subtasks(key)) { %sk%.status = "Closed"; } }
Best Regards,
Silviu
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
can you share your code ??
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.