How do I get a parent to resolve automatically when all sub-tasks are resolved

David Etheridge June 13, 2011

How can I get this to work?: when the last of >1 sub-tasks is finally resolved it transitions the parent to resolved, and not until all subtasks are resolved. This should work, in theory: in the sub-task workflow, on the 'resolve' transition, I set the _last_ post function to trigger an update of the parents resolution field to 'resolved'. All alone this does work, but the first subtask updated to resolved will resolve the parent even when other subtasks are open. So, on the parent task workflow for the resolve transition I set the "sub-task blocking condition" to restrict the resolve transition until all sub-tasks are themselves resolved. Expected Results: the first subtask to be resolved triggers an update of the parent which fails due to the parents' subtask blocking condition which requires all subtasks to be resolved before the parent can be resolved. When the last subtask is resolved, its post functions are triggered (commit comment, update self to resolved, index self, fire generic event, etc,) ending with the trigger to update parents resolution field to resolved. In theory, the subtask has updated itself (and reindexed) before the trigger fires so the parents' subtask blocking condition is satisfied and the parent should update. It doesn't. Again, if I remove the blocking condition on the parent the first subtask resolved resolves the parent, but that's not the goal.

4 answers

1 accepted

9 votes
Answer accepted
JamieA
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 13, 2011

This is available as one of the built-in scripts in the script runner plugin - Transition parent when all subtasks are resolved. As you say you put this as a post-function on the sub-task workflow. You can specify which transition to use on the parent issue and which resolution to use. It can also be used as a listener.

The plugin home page is here: Script Runner.

If you want to make your own hook work it sounds like you just need to check the sub-task siblings resolution.

Deleted user August 11, 2011

Hi Jamie,

This is really a functionality that I'm also looking for. But the catch is I'm on JIRA Studio. Is this plugin somehow available on JIRA Studio as well

I couldn't find it on the plugins page in my Studio

JamieA
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 19, 2011

Hi Nikhil,

It's not available for jira studio, and very unlikely ever to be.

jamie

Simon Ward November 29, 2012

Hi Jamie - do you know if the parent transition mentioned above will do its associated post functions? I am using this to create more subtasks when the 1st set are all signed off and it's not working. any suggestions gratefully received

JamieA
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 30, 2012

Yep, the parent post-functions will run.

Simon Ward December 2, 2012

Hi Jamie

Sorry to bug you again, but I can't seem to get this to work.

I have a parent task and it's associated workflow, within which I am creating subtasks on transition.

I have 2 further sub task issue types, each with their own workflow.

When all sub-tasks of type a are resolved, I am trying to create sub tasks of type b, and assign them using the create sub task on transition plugin from LLC. This plugin is working fine for the 1st transition, which is done manually, but I get the following error when I try to transition using your plugin.

2012-12-03 16:30:12,472 http-8081-1 ERROR busso2 990x2665x1 h1qtrv 10.144.42.120 /secure/WorkflowUIDispatcher.jspa [atlassian.jira.workflow.OSWorkflowManager] Caught exception while attempting to perform action 781 from workflow 10246 on issue 'DEAL-223'
java.lang.NullPointerException

Then:

2012-12-03 16:30:12,472 http-8081-1 ERROR busso2 990x2665x1 h1qtrv 10.144.42.120 /secure/WorkflowUIDispatcher.jspa [groovy.canned.utils.WorkflowUtils] Errors: {}
Error Messages: [null]

I have created two sub task workflows to handle the difference in parent action between the two sub tasks.

any advice gratefully accepted

Regards

Simon

Simon Ward December 6, 2012

Hi Jamie

All sorted out - I hadn't added the new sub task issue types to the custom fields I was trying to duplicate from the Parent to the sub tasks.

Gianni Pucciani August 6, 2015

Hi Jamie, I just updated ScriptRunner to version 3.1.4, but in the postfunctions I only see *transition parent issue* which require scripting. I did not find *Transition parent when all subtasks are resolved* as mentioned in your reply, am I missing something? Thank you!

Gianni Pucciani August 6, 2015

Hi, Apologies, found the script in the Scripted functions.

1 vote
DavidV June 13, 2011

This is a good question - and it would be awesome to have a plugin where if the last subtask of an issue is resolved/closed it would resolve/close the parent task.

CustomWare does develop custom plugins like this, although we have not released such plugins publicly. Yet for a couple of days development we could put something together like this for you. If you are interested - email us at info_at_customware.net

1 vote
Jeremy Largman
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
June 13, 2011

I'm not sure this can be done out of the box, and I couldn't find a plugin. There are a few ways to handle this programatically. One would be to write an event and a listener. Alternatively, you could use the CLI to run a script to check subtasks programatically.

0 votes
Natalie Hobson
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 1, 2013

Move the post function that triggers the parent transition to be last (at the bottom) of all the other post functions on the transition - otherwise the database hasn't put the sub-task issue to the status that you have stated is allowed in the parent workflow's condition (or validator) yet. :)

David Etheridge August 2, 2013

Thanks for the answer. That's exactly what I mentioned in the initail post, which is now 2 years old (wow). So, maybe it works now in later versions. Pls lmk if this works for you today and what version of JIRA you're using, and I'll give it another try.

David Etheridge August 2, 2013

Thanks for the answer. That's exactly what I mentioned in the initail post, which is now 2 years old (wow). So, maybe it works now in later versions. Pls lmk if this works for you today and what version of JIRA you're using, and I'll give it another try.

Natalie Hobson
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 2, 2013

Haha, sorry to bump it when it's so old (I was searching for some other questions when I came across it and noticed it didn't have an accepted answer yet) - yes, it works perfectly for me in our instance (we are on JIRA 5.2). If it's still not working, you might want to double check what you've set in the condition/validator and ensure that the situation fits (you might have an incorrect status selected?). :)

Suggest an answer

Log in or Sign up to answer