How can I have a Story automatically update when all of its linked Tasks are DONE?
Asked by Rich Evers:

Much like the automation rule where an Epic will automatically update when all of it's Stories are updated to DONE, I want to do the same with Stories and their linked Tasks.


Answers:
author: Curt Holley
body: Hi [@Rich Evers](/t5/user/viewprofilepage/user-id/4538454)

Welcome to the community.

You might wanna get more conditional (I know I would), but the basic version of the automation would be something like:

![auto.png](https://community.atlassian.com/t5/image/serverpage/image-id/174831iB169588C1F73D03B/image-size/large?v=v2&px=999 "auto.png")

comments: author: Rich Evers
body: Not sure how I would need to get more conditional, but I did exactly the above and it didn't work.


author: Bill Sheboy
body: Hi [@Rich Evers](/t5/user/viewprofilepage/user-id/4538454) -- Welcome to the Atlassian Community!

To confirm your use case, which do you mean:

1. when all of the sub-tasks of a story complete, do \<X\>
2. when all of the linked issues (of any type) of a story complete, do \<X\>
3. something else?

Case #1 can be done in one automation rule, triggered on the sub-task changing. There may be an example in the template library like this.

Case #2 *probably* can be done in one rule, triggered on a schedule (for the story) or from the linked issue, probably using branches, lookup issues, and created variables. It *definitely and safely* can be done in two rules, with the original linked issue triggering another rule to get the story to check its linked issues.

Kind regards,  
Bill

comments: author: Curt Holley
body: Good point [@Bill Sheboy](/t5/user/viewprofilepage/user-id/1685313)

My example is all about linked issues [@Rich Evers](/t5/user/viewprofilepage/user-id/4538454) but either/both can be done.

Other complexities may arise from different workflows and or different "Done" status categories within...resolution codes (if required) etc. But all very doable.

let us know ow you get on.


author: Rich Evers
body: Case #2. When all of the linked Tasks of a Story are updated to DONE, automatically update Story to Done. I've tried retrofitting the rule that Jira has pre-defined for the parent-child relationship with Epics and Stories, replacing "parents" and "childs" with "linked" but for whatever reason is not working out.


author: Curt Holley
body: For Case#2. Can you show us the rule and any info in the audit logs?


author: Rich Evers
body: ![Screen Shot 2021-12-20 at 3.13.00 PM.png](https://community.atlassian.com/t5/image/serverpage/image-id/174836i5EA157E6BB61A0F2/image-size/large?v=v2&px=999 "Screen Shot 2021-12-20 at 3.13.00 PM.png")


author: Curt Holley
body: The "For stories (or other issues in Epic)" branch only works if the trigger issue is an Epic.

Try a linked issues branch


author: Rich Evers
body: No good. Thanks, though.


author: Bill Sheboy
body: Rich, based on your rule and Curt's ideas, does your rule now look like this? Note I made a substitution in the JQL to check statusCategory instead of status.
> Please note: given the possible slowness of this rule, I still think it might cause a run-away, looping condition. Perhaps the 2-rule approach will cause the hard-stop to prevent this, but it would require some assumptions you have not stated, such as the number and type of linked issues.

![Capture.PNG](https://community.atlassian.com/t5/image/serverpage/image-id/174844iDF34B47AAE9C83CB/image-dimensions/290x480?v=v2 "Capture.PNG")


author: Rich Evers
body: I don't have the options to build it that way. It will only let me do **Types: All link types** and that is it. From there it is only allowing me to chose a condition. See below: ![Screen Shot 2021-12-20 at 8.39.22 PM.png](https://community.atlassian.com/t5/image/serverpage/image-id/174857iFB98BFFE44A74970/image-size/large?v=v2&px=999 "Screen Shot 2021-12-20 at 8.39.22 PM.png")


author: Bill Sheboy
body: Please try changing the Condition to "all match specified JQL" to see that option.


author: Rich Evers
body: If I do that, then I need to manually enter in a field here...![Screen Shot 2021-12-24 at 2.45.43 PM.png](https://community.atlassian.com/t5/image/serverpage/image-id/175311iDF7E9B4E7E014919/image-size/large?v=v2&px=999 "Screen Shot 2021-12-24 at 2.45.43 PM.png")


author: Rich Evers
body: I've tried putting in various things here and it has errored out.


author: Bill Sheboy
body: What have you tried putting in the "matching JQL" field? What is happening when it errors out?

Please try:

```
statusCategory = Done
```


author: Rich Evers
body: I did what suggested above, and it didn't work. It did not give me an error message, though. Thanks for the attempt, though!


author: Bill Sheboy
body: Hi, Rich.

Just to confirm, would you please post images of your current rule and an audit log details from an attempted execution? That may reveal something I am not seeing from trying to help, one rule component at a time. Thanks!


author: Rich Evers
body: ![Screen Shot 2021-12-29 at 2.46.26 PM.png](https://community.atlassian.com/t5/image/serverpage/image-id/175626iC64050C335EB3C54/image-size/large?v=v2&px=999 "Screen Shot 2021-12-29 at 2.46.26 PM.png")![Screen Shot 2021-12-29 at 2.56.19 PM.png](https://community.atlassian.com/t5/image/serverpage/image-id/175627i5107488C20B730C8/image-size/large?v=v2&px=999 "Screen Shot 2021-12-29 at 2.56.19 PM.png")I can't seem to figure out what project restriction may be prohibiting the results I'm seeking.


author: Bill Sheboy
body: Thanks for those images. Okay...

* TESTRICH-33 transitioned to Done, and
* it is linked to TESTRICH-30...so that one was processed in the branch, and
* TESTRICH-30 did not meet a condition

What is the current status of TESTRICH-30?

1. If it is not Done, the first condition was not matched
2. If it is Done, it is the second condition which needs investigation.


author: Rich Evers
body: 30 did not update to done. The link "how" I guess, are all labeled as "relates to." I guess another question, is that why can't we have a parent-child relationship with stories and epics, like we do epics and stories? That is ultimately what I'm trying to do. Am I going about this the correct way?


author: Bill Sheboy
body: For epics and stories/tasks/bugs, the relationships are easier:

* when going from epic to children, use the built-in branch option
* when going from children to epic, use a JQL branch with "epic link" = {{triggerIssue.epic link}}

My understanding was you were evaluating any links, and not just epic/children. Was I incorrect?


author: Rich Evers
body: Correct, I think. All I want to see happen is that when all the tasks are updated to DONE that are assigned to a specific story, the said story will update to DONE as well.  

The hard part is that I'm not a tech-y software guy, so all of this language and how the software works is very foreign. I just want to it work and do things that I want it to do. :)


author: Bill Sheboy
body: Let's confirm how you use issues In Jira as that will confirm we are talking about the same thing. In Jira, you can relate issues with a hierarchy and/or linked issues:

++Hierarchy of issues++

* Epics
  * Stories
    * Subtasks

++Linked issues++

* Any issue (Epic, Story, Task, Subtask, Bug), linked to another issue

Which of these matches what you are doing: hierarchy or linked?


author: Rich Evers
body: * epics
  * stories
    * tasks

Trying to link tasks to stories because there is no ability to create a parent-child relationship between the two. Epics and stories have the parent-child relationship already pre-built in the software.


author: Bill Sheboy
body: Thanks!

Next, can any single Task be linked to multiple Stories? (Note there is no restriction to this in Jira so this would just be manually enforced.)

If so, what you describe cannot be done with automation rules. The act of checking from Task --\> Story --\> Task --\> Story... could create a loop.


author: Rich Evers
body: Negative. A task belongs to a single dedicated story.


author: Bill Sheboy
body: Okay, then let's try this one for Task to Story to Tasks, using lookup issues to check the counts, step by step

* trigger: issue transitioned to Done
* condition: issue type is Task
* action: lookup issues to get the one-and-only-one Story (if any exist)
  * JQL: issue IN linkedIssues( {{triggerIssue.key}} )
* advanced compare condition: {{lookupIssues.size\|0}} equals 1
* advanced compare condition: {{lookupIssues.first.issueType}} equals Story
* action: create variable for varStoryKey set to {{lookupIssues.first.key}}
* action: lookup issues to get any issues linked to the story which are not done
  * JQL: issue IN linkedIssues( {{varStoryKey}} ) AND statusCategory != Done
* advanced compare condition: {{lookupIssues.size\|0}} equals 0
* branch: on JQL to the story with key = {{varStoryKey}}
  * action: transition the story issue, copying from trigger issue (Done)


author: Neelam Manhas
body: I am looking to create the same automation as requested originally, wondering if this worked? and what i need to do the following below.

looking for the following:

when all Tasks in Project 1 are set to status DONE, i want the user story that they are linked to in with Project 2 to be set to Ready to Test and I want the assignee updated at the same time. (hierarchy being used is User story ==\> multiple tasks to complete the user story)


Tags: atl-orange