Fix all the wrong Initiative# field values
Asked by Jiten Khanna:

I want to create an Automation rule in which all the issues which has the Parent (Initiative issuetype) Initiative# field value should make the child (Epic, Story issuetype) Initiative# field value same especially the ones which are wrong. So for example in the below snip the Parent has the correct value but the child doesn't show the right value. So it should be RIT-337 but Epic \& Story is showing PMO-442![Parent Intiative#.JPG](https://community.atlassian.com/t5/image/serverpage/image-id/272466i14830B5B3F497BFE/image-size/large?v=v2&px=999 "Parent Intiative#.JPG")![Story Initiative#.JPG](https://community.atlassian.com/t5/image/serverpage/image-id/272467i94657FAEB452CCDE/image-size/large?v=v2&px=999 "Story Initiative#.JPG")


Answers:
author: Bill Sheboy
body: Hi [@Jiten Khanna](/t5/user/viewprofilepage/user-id/5280817)

First thing, have you investigated why those child (and grandchild) issues' values for the field are different? Were these entry errors, planned differences, or has the issue hierarchy changed in a way to make them incorrect? Knowing this will help guide the scope of your change...because using an automation rule for this type of change will not be easily reversible if done incorrectly.

Next...some questions may help the community to offer solution approaches:

* Are you using Jira Cloud or Server / Data Center version?
* What is the scope of this change: one Jira project, or multiple projects?
* What is your plan to keep these values synchronized over time?

Until we learn those answers...I believe you could do this with multiple rules to initially fix the condition (one for each parent/child level pairing), and then several more rules to keep the values in synch over time.

If you have already started your rules, please post images of them and the audit log details showing the rule execution. Those will provide more context for the community to help. Thanks!

Kind regards,  
Bill

comments: author: Jiten Khanna
body: Hello [@Bill Sheboy](/t5/user/viewprofilepage/user-id/1685313) ,

So what I can see is that there is an Automation which did the trigger on June 17 from Blank to PMO-442 for Child issues and Parent one happened last month by Automation as well from PMO-442 to RIT-337. I have added the snip below for the 2 automations currently exists

* It's for JIRA Cloud
* Multiple Projects/ Globally
* Don't know what to answer for your 3rd point but it should always be as per the issuetype- Initiative which is a Parent![Initiative#.JPG](https://community.atlassian.com/t5/image/serverpage/image-id/272501i9A10EFA4C1278DDC/image-size/large?v=v2&px=999 "Initiative#.JPG")![Initiative-Story#.JPG](https://community.atlassian.com/t5/image/serverpage/image-id/272503i2C969B94CF380B6A/image-size/large?v=v2&px=999 "Initiative-Story#.JPG")


author: Bill Sheboy
body: From the information you provided, I infer you have the Premium license level of Jira Cloud:

* Otherwise the function portfolioChildIssuesOf() would not work
* And, running a global automation rule on this scale may only be practical for a Premium license; otherwise the site would use up its automation limit for global rule execution.

*You show two rules, and now I wonder what is not working as you expect?*

Synchronizing a field across this many issue type levels can require either several rules (to update as changes occur), or a single, scheduled trigger rule to do this periodically (e.g., daily).

A better approach may be to consider: which issue type level "owns" this information, and to only store the value at that level.

For your question's scenario, I anticipate you will need rules covering at least these use cases:

1. When the value changes for Initiative #, and the issue type is **Initiative**, then update all of the child issues using a branch on portfolioChildIssuesOf()
2. When the value changes for Initiative #, and the issue type is **Epic**, then reset the value back to the parent value. This handles any manual edit/overrides of the field.
3. When the value changes for Initiative #, and the issue type is **Story, Task, or Bug**, then reset the value back to the parent value (assuming the parent Epic is correct). This handles any manual edit/overrides of the field.
4. When an issue is created, and the issue type is **Epic**, and there is a parent Initiative, then set the field to the parent value
5. Repeat #4 for created **Story, Task, or Bug** issues, setting to Epic field value
6. When the parent changes, and the issue type is **Epic**, then update the field value and the value for all of the Epic's children
7. When the parent changes, and the issue type is **Story, Task, or Bug**, then update the field value to match the new parent
8. UNKNOWN: what should happen to your field value when an issue is deleted from the hierarchy? For example, when an Epic has child Stories and an Initiative parent, and the Epic is deleted.
9. ...other scenarios I missed...

None of these rules should enable the "Allow rule trigger" option, or they would quickly create a cascade of looped processing, and halt automation execution. It may be possible to do this with fewer rules using that option, although that will be harder to maintain and diagnose problems.


author: Jiten Khanna
body: Hello [@Bill Sheboy](/t5/user/viewprofilepage/user-id/1685313) ,

Thank you for your inputs so you want me to create 7 Automation rules but I quite didn't understand your Point 8 \& 9 what you meant, could you elaborate please.


author: Bill Sheboy
body: Sorry for my long answer; perhaps I gave too much information...

I strongly suggest considering: *why do you want that field in sync* for the issues in the entire hierarchy? Although the rules can do this, it may not be a better answer to the problem you are trying to solve.

For #8...when an issue such as an Epic is deleted, the child issues' Epic Link is cleared. I do not recall if that will trigger a rule as a "parent" change. My question was: what do you want to happen to a Story's Initiative# field when it is no longer connected in a chain of issues?

For #9...I do not know what I may have missed for your scenario.

I encourage you to meet with your Jira admin to describe the problem and needs, and they may help identify other things required to solve the problem.


author: Jiten Khanna
body: [@Bill Sheboy](/t5/user/viewprofilepage/user-id/1685313) don't have to be sorry also I don't want the field to be in sync as long it's providing the correct value under Initiative# from the parents.

So usually none of the child issues would be orphan as every child needs to have a parent, if Epic is deleted then that's fine to have the child value cleared because then that child would either be mapped to another parent or deleted as well. Yes, I don't want to happen to Story which are not connected to a parent which I am stating in my rule anyway which I sent earlier.

So now what I have created already the 2 rules does that needs to be changed? Shall I now create those 7 new rules along with what I have or does it need to be part of the same rule? Please advise, thank you


author: Bill Sheboy
body: Your scenario will determine which rules you need. Specifically,

* how often do you need this field to be accurate for the child issues: always or periodically (such as daily)?
  * *When you need the field updated "at all times", you need several rules to keep things in sync. When you need a periodic update, a single scheduled rule could work.*
* at what level do you expect the field to change?  
  * If you only expect the value to be set at the Initiative issue level, and then used by other issues, you can do this sync with fewer rules. If instead anyone can change the field at any level, you need lots of rules.

Again, I encourage you to meet with your Jira Admin to map out and create these rules. Rules like this can be challenging and your admin can help.


author: Jiten Khanna
body: Thank you [@Bill Sheboy](/t5/user/viewprofilepage/user-id/1685313) so the field should be run daily or always should be updated. I expect it to be set only at the Initiative issuetype level so that all the child issues are updated automatically with no manual edits because I'll remove that field from screen scheme under Epic and Child issues.


author: Bill Sheboy
body: If you want to update once per day, your original rule that branches through all the child issues will work.

If you want to always update, you will need multiple rules, probably with 3 for each level (triggered on issue create, triggered on Initiative# changed, and triggered on parent changed).