How to set the status of Parent Issue based on the statuses of Child issues in Jira data center
Asked by Digvijay Singh Gehlot:

Hi Community,

I have a typical mapping requirement regarding Parent-Child relation between Initiative and Epics.

Pre-conditions:

* I have a Parent Project (as Project P) with issue type level as Initiative and two Child Projects (as Project C1 and Project C2) with issue type level as Epic 1 and Epic 2 respectively.
* In Project P, I have five statuses: Intake \> Pre-checks \> Assessments \> In-Scope \> Closed
* In both Projects C1 \& C2, the statuses are: Open \> In-Progress \> In QA Review \> Done

Current workflow:

* When a new issue (as Parent) is created in Project P with Initiative issue type, then I am cloning the issue as Child in Project C1 and C2 with Epic issue type via Jira automation.

Requirement is:

* When child Epics transition from one status to another in their respective Projects (C1 \& C2), I want to set a specific status of Initiative in Project P based on the current statuses of epics automatically.

For eg:

* If Epic 1 = In-Progress; Epic 2 = In-Progress then Initiative = Pre-checks
* If Epic 1 = In-Progress; Epic 2 = In QA Review; then Initiative = Assessment
* If Epic 1 = In QA Review; Epic 2 = In-Progress; then Initiative = Assessment
* If Epic 1 = In QA Review; Epic 2 = In QA Review; then Initiative = In-Scope

Please guide on how I can configure the above use-case with the help of Jira automation, scriptrunner, JMWE app or any Post functions.

It would be a great learning for me.

Thanks


Answers:
author: Hans Polder
body: HI [@Digvijay Singh Gehlot](/t5/user/viewprofilepage/user-id/5431110) ,

Thanks for clearly explaining your use case and requirements. This should be quite easily achievable using Automation. It might be depending on the version of Jira and/or the Automation plugin for Data Center, but in my 9.12 Jira DC test setup this should work for the In Progress status.

![Screenshot 2024-08-01 125218.png](https://community.atlassian.com/t5/image/serverpage/image-id/339398i644E97317FCE8AF7/image-size/large?v=v2&px=999 "Screenshot 2024-08-01 125218.png")

Similarly, you could create a copy of this rule for the Assessment setup, or try to combine it in one automation rule with another Parent branch, like so:

![Screenshot 2024-08-01 125442.png](https://community.atlassian.com/t5/image/serverpage/image-id/339400iF5F82A8027AF0896/image-size/large?v=v2&px=999 "Screenshot 2024-08-01 125442.png")

comments: author: Digvijay Singh Gehlot
body: Hi [@Hans Polder](/t5/user/viewprofilepage/user-id/5506451)

Thank you for your detailed explanation.

I tried configuring the same but not able to execute it successfully in any of the Child Projects.

I believe, we need to add all the three projects (P, C1, C2) in the Global Rule Details, as I want to set the status of Initiative (Parent issue) present in Project P based on the status of Epics (Child issues) present in Project C1 \& C2.

However, after configuring the same automation logic under Admin settings \> Automation rules \> Global rule and performing the below steps:

* Created a new Initiative in Project P.
* Created a new Epic 1 in Project C1, and added Initiative in "Parent Link"
* Created a new Epic 2 in Project C2, and added Initiative in "Parent Link"
* In Epic 1 - change the status from Open to In Progress
* In Epic 2 - change the status from Open to In Progress

The Audit Log is showing "No Actions Performed" and there is no status update in Initiative of Project P.

May you guide me further?

Thanks


author: Digvijay Singh Gehlot
body: Just an another thought, is Branch - For Parent may be impacting in the automation?

* As Branch - For Parent says, "Finds the parent issue of the sub-task that triggered this rule."
* And in my case, I have created a higher level of hierarchy as Initiative above the Epic in Advanced Roadmaps. And I am using Initiative as only on issue type in Project P and Epic as only one issue type in Project C1 and C2?

So, in Rule, will it find the parent issue if there is a sub-task linked as Child? And is something related to "Parent Link" field?

Looking forward to hearing from you soon.


author: Hans Polder
body: [@Digvijay Singh Gehlot](/t5/user/viewprofilepage/user-id/5431110) ,

* A **Global** Rule will always work across your entire environment, however if the Epics and Initiatives are only in a few projects, you can definitely make it a **Multi-Project** rule and define the specific projects that contain these type of tickets.
  * If the situation is stable, definitely choose 'Multi Project Rule' as you will have less chance of inadvertently impacting other issues totally outside the scope of your intended automation.
* I agree with the unclarity about the 'Parent' branch option, I was misled since in Cloud the 'Parent' option should look higher, I believe.

Regardless, I spent quite some time trying to make it work. And I got it to work, but I'm wondering if this is the best solution.

[@Bill Sheboy](/t5/user/viewprofilepage/user-id/1685313) could you please, as Automation Guru, validate and find any improvement opportunities if there are any?

**The solution I found:**

JQL used in the lookup issues step: "Parent Link" = {{triggerIssue.Parent Link}}

![Screenshot 2024-08-01 171442.png](https://community.atlassian.com/t5/image/serverpage/image-id/339479iFB50A29B579DDE93/image-size/large?v=v2&px=999 "Screenshot 2024-08-01 171442.png")

JQL used in the branch: key in ( {{childissues}} )

![Screenshot 2024-08-01 171519.png](https://community.atlassian.com/t5/image/serverpage/image-id/339480iA0E37882A85D44FE/image-size/large?v=v2&px=999 "Screenshot 2024-08-01 171519.png")


author: Hans Polder
body: Keep in mind by the way that the lookupissues function is limited to (I believe) a 100 issues maximum. As long as you don't put more than 100 Epics under a Initiative you should be good to go.


author: Bill Sheboy
body: Hi [@Digvijay Singh Gehlot](/t5/user/viewprofilepage/user-id/5431110) and [@Hans Polder](/t5/user/viewprofilepage/user-id/5506451)

I agree with the suggestion to use a JQL branch for this scenario. The smart values and hierarchy may be different than the built-in assumptions for parent branching.

Hans, I note you using the Lookup Issues action but then using different JQL in the branch. Did you intend that?

Back to the original scenario...

I believe using branch on JQL to access the parent Initiative, then using the Related Issues Condition with JQL could cover each case. But this may potentially lead to some timing / racetrack errors where the Initiative transitions multiple times during the same rule.

The fix could use what Hans noted with Lookup Issues:

* gather all of the Epics for the Initiative *once* with the Lookup Issues action
* using the if / else structure
  * use the smart value condition (still called Advanced Compare in Data Center), and [smart value, list filtering](https://community.atlassian.com/t5/Automation-articles/Filtering-smart-value-lists/ba-p/1827588), check one of the conditions for the child Epic status values
  * when needed, branch to the parent using JQL, and transition the status
* else / if for the next set of conditions
  * ...

If I was implementing this, I would use Create Variable after the Lookup Issues to first calculate counts for the Epics and their status values. Then use those variables in the condition checks. This would allow writing the variables to the audit log to help with testing / debugging.

For example, the count for epics In-Progress could be this:

* action: create variable
  * name: varEpicsInProgress
  * smart value:

```
{{#=}}0{{#lookupIssues}}{{#if(equals(status.name,"In-Progress"))}}+1{{/}}{{/}}{{/}}
```

Kind regards,  
Bill


author: Hans Polder
body: Thanks for the help [@Bill Sheboy](/t5/user/viewprofilepage/user-id/1685313) ,

My approach was as follows:

1. Lookup all issues that have 'Parent Link' as 'triggerissue.Parent Link' (a.k.a.: all Epics that have the same Initiative as parent)
2. Create a variable for the results of this lookup called childissues (I checked with the audit log, it saves multiple items correctly)
3. Then, the branch only applies to the single Initiative that needs attention. So, 'key = Parent Link' results in the actual Initiative ticket that needs to be checked
4. Then, when in the branch, check if the condition is true that the child issues are all 'In Progress' (but maybe this could be moved outside the branch as well, don't know if that would matter?).

That smart value that you used for the varEpicsInProgress variable, is that something that just flows out of your fingers, or is there some sort of standard/tool/format that you use? It's pretty prone to error I can imagine, just forgetting one character would break it.


author: Digvijay Singh Gehlot
body: Hi [@Hans Polder](/t5/user/viewprofilepage/user-id/5506451) , [@Bill Sheboy](/t5/user/viewprofilepage/user-id/1685313) ,

Thank you for your detailed explanation.

I followed both of your instructions in configuring the Rule with multiple projects restrictions as below:

First, I followed the same rule steps as suggested by Hans and observed that:

* When passing JQL query: "Parent Link" = {{triggerIssue.Parent Link}}, and clicking on Validate query, no issue counts are appearing on that Action. Is it expected that I will not the issue counts when clicking on Validate query although there are Epics linked with Initiative?
* However, when I moved the Epic (Child issue) to "In Progress" status in Project C1, the Hans Rule was executed but I didn't see any status update on the Initiative (Parent issue) in Project P.
* Audit log says:

1. Issue Condition: the following issues passed: \<epic issue key in Project C1\>
2. Lookup issues action was performed successfully.
3. Related issues condition: the following issues did not match the condition: \<initiative issuekey of Project P\>

Second, I followed Bill's suggestion by making the changes in Create Variable in Hans Rule and observed that:

* Audit log:

1. Issue condition: the following issues passed. \<epic issuekey of Project C1\>
2. Lookup issues action was performed successfully.
3. Related issue condition:  
   JQL search failed for some issues. This is most likely because the JQL with smart-values was not valid for this query:  
   "(key in ()) AND (project in (\<projid P, projid C1, projid C2\>)" - Error in JQL Query: Expecting either a value, list or function but got ')'. You must surround ')' in quotation marks to use it as a value. (line 1, character 12).
4. The following issues did not match the condition: \<initiative issuekey of Project p\>

Please guide me further if I am missing any configuration in the Rule creation, I will make the necessary changes and then share my observations with you.

Thanks


author: Hans Polder
body: Hi,

It's hard to imagine all this without seeing actual screenshots. Can you please add these?

Also, it would be wise to add some 'Log Actions' in your automation so we can observe where it's going wrong.

So:

1. Add one Log action after 'If issuetype equals Epic', logging: **Triggerissue.Parentlink={{triggerIssue.Parent Link}}**
2. Add one Log action after 'Create variable', logging: Child issues =**{{childissues}}**
3. and any other you might feel relevant

If you share the screenshot of your automation as well as the audit log, we can troubleshoot much quicker.


author: Bill Sheboy
body: Hi [@Hans Polder](/t5/user/viewprofilepage/user-id/5506451)

Regarding your question:
> That smart value that you used for the varEpicsInProgress variable, is that something that just flows out of your fingers, or is there some sort of standard/tool/format that you use? It's pretty prone to error I can imagine, just forgetting one character would break it.

I write smart value, expressions like that so often I have learned to first create them in a coding text editor, such a Notepad++ with plugins. That ensures the syntax and bracketing match up. Only then do I copy them over to a rule for validation testing. This approach also helps me progressively improve them, seeing all versions...as change history is not visible in the automation rule editor.

And...I keep testing Jira projects specifically with template rules / expressions I expect to reuse.


author: Hans Polder
body: Thanks for your tips Bill, I'm eager to learn more - however let's keep this thread on-topic. I've created a separate thread here: <https://community.atlassian.com/t5/Jira-questions/How-can-I-ensure-quality-smart-values-that-are-complex/qaq-p/2774247#M1039761> \> hopefully you would be willing to lend a hand there to get me started? Much appreciated!


author: Digvijay Singh Gehlot
body: Hi [@Hans Polder](/t5/user/viewprofilepage/user-id/5506451) , [@Bill Sheboy](/t5/user/viewprofilepage/user-id/1685313) ,

I would like to share the screenshots of my Rule as requested below:

1) This is Rule details of my Rule:

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

2) This is the Audit log after configuring Rule and executing the required action:

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

3) This is the first part of the Rule:

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

4) This is the second part of the Rule:

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

I have tried multiple times to configure the rule as per your suggestions but I am unable to see Status update of Parent Issue in Project P based on the Status update of Child Issues in Project C1 and Project C2.

Please guide me further with an appropriate solution.

Thanks


author: Bill Sheboy
body: To help with context, please post an image of the entire rule in one picture and of the entire audit log details showing the rule run in one picture.

You can get those into one image using either an app or a browser extension which supports scrolling page image capture.

Next, if you view the audit log and compare to the rule steps shown {{childissues}} is empty. Where are you getting / setting the value of that smart value?


author: Digvijay Singh Gehlot
body: Hi [@Ram Kumar Aravindakshan _Adaptavist_](/t5/user/viewprofilepage/user-id/2988015)

Could you help me to achieve this use-case here: <https://community.atlassian.com/t5/Jira-questions/How-to-set-the-status-of-Parent-Issue-based-on-the-statuses-of/qaq-p/2772641>

By using Scriptrunner?

It would be a great learning for me to extend my knowledge of Scriptrunner scripting.

Looking forward to hearing from you soon.

Thanks


Tags: advanced-roadmaps

data-center

epic-link

initiative

jira-data-center

jmwe-app

parent

parent-link

post-function

scriptrunner

status