Automation close parent issue
Asked by Urmo Luts:

Hi

I have project where i have main issue. When user click IN PROGRESS then there is one sub-task and 2 another ticket into another Jira project. Relates to issue link between main ticket and another project tickets.

Now when Relates to and sub-task status is Closed, how i should write automation what close main ticket also?

**WHEN** Issue transitioned to Closed  
**IF** Issue Type equals Sub-task  
**For Parent**   
**IF** Sub-task match status = closed

**Then** Transition the issue to Closed  

but how i should add relates to issues into this ?


Answers:
author: Stefan Salzl
body: Hi [@Urmo Luts](/t5/user/viewprofilepage/user-id/4595666) ,

As far as I understand your requirement this needs to be scoped from 2 sides. Let?s wrap this up a little bit:  

2 projects:

* project A
  * Task 1
    * Subtask 1.1
    * Subtask 1.2
* project B
  * Task 2 --\> relates to Task 1 (in project A)

So from my point of view the use case you described has 2 entry points:

1. **given** : subtask of Task 1 is closed
   1. **when** all other subtasks of Task 1 are closed (needs to be checked)
   2. **and when** Task 2 in project B (that is linked to Task A) is closed (needs to be checked)
      1. **then** transistion Task A to closed
2. **given** : Task 2 in project B is closed
   1. **when** all subtask of Task A (that is linked with relates to) are closed
      1. **then**: transition Task A to closed

Does this describe your use case and also an idea of your automation rule(s) ?

Looking forward to your feedback.

Best  
Stefan

comments: author: Urmo Luts
body: Hi

Seems to be that right now is working when last closing issue is sub-task. But when another issue from Project Kommunikatsioon or Kasutajatugi, then it does not work.

I have sub-task + two another jira project and they have different closing status (Done, Resolved, Closed).

Yes i know there is today too much status what do same thing but i'm working to close up this old solution.

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

Urmo


author: Stefan Salzl
body: Hi [@Urmo Luts](/t5/user/viewprofilepage/user-id/4595666) ,

As I mentioned splitting this use case into 2 different rules would make it easier and doesn?t really need for checking projects as the main condition is the status of wheter subtasks or linked issues.

Your use case obviously has 2 different triggers and for each trigger it?s necessary to check different conditions. Therefore i would suggest to create 2 different rules.

Best  
Stefan


author: Urmo Luts
body: Hi [@Stefan Salzl](/t5/user/viewprofilepage/user-id/4616993)

I made one long automation into two. Seems to be that sub-task close work fine but this when sub-task's are closed but relates to tickets are opened but after last relatest tickets closed it does not close.

![image.png](https://community.atlassian.com/t5/image/serverpage/image-id/195455i8D396315C9645CA4/image-dimensions/433x568?v=v2 "image.png")


author: Stefan Salzl
body: Hi [@Urmo Luts](/t5/user/viewprofilepage/user-id/4595666)

I tried to reproduce what I got from your description:

++**Rule 1 - trigger is transition from linked issue (relates to) to done**++

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

++**Rule 2 - triggers when subtask is transitioned to done (then checks if other subtasks exist and all are done and if related issue exists and is done)**++

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

This is the most simple version of the described requirement. Issue types and status needs to be set according to your configuration.

Best  
Stefan


author: Urmo Luts
body: Hi

Seems to be that it allmost works but i think i had made some error into.

Right now is one relates to is closed/resolved/done, then parent issue is closed also.

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

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

Seems to be that i have done something wrong...


author: Stefan Salzl
body: mhm....got it.

Within the branch (where you change context of the automation rule to the issue that should be closed) add a condition that checks if there are other linked issues with status "not closed" (like the other rule is checking for other open subtasks).

Could look like similar to following:

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

Best  
Stefan


Tags: data-center