Hi community!
We have the following type of issue hierarchy in use, where the issues of different hierarchies are linked to each other with a parent link.
1. Initiative
1.1 Feature
1.1.1 Epic
1.1.1.1 Story

In addition, we link horizontal dependencies to other products within our value stream to Capabilities with contributes to-link.
I'm struggling to find a way to create a structure with the whole product hierarchy (Initiative-Feature-Epic-Story) but that it would only include those issues that are linked with the "contributes to" link to a specific capability.
In this example case (in the picture) i would want my Structure folder to contain only these issues:
- Iniative
- Feature 1
- Epic 1.2
- Story 1.2.1
- Story 1.2.2
- Story 1.2.3
- Epic 1.3
- Feature 2
At the moment my automation includes these steps:
- Insert jql: project = "PRODUCT ABC" and issuetype = Initiative
- Extend with Advanced Roadmaps(Portfolio) child issues
- Add issues belonging to epics
- Filter by JQL Query: issueFunction in linkedIssuesOf("issuetype = "Capability", "is achieved by")
The problem is, that:
- if I select the "Show all sub-items of matching items" in the Filter by JQL Query, it also returns eg. epic 2.1, epic 2.2 and epic 2.3.
- if I don't choose the "Show all sub-items of matching items" or filter on level 3, it then drops the story 1.3.2 away from the Structure.
Basically the logic is something like this:
- IF issuetype = Feature AND the issue is linked to Capability (with a "contributes to"- link): show only those issues that are linked with a "contributes to"- link to the Capability
- IF issuetype = Epic AND the issue is linked to Capability (with a "contributes to"- link): : show only those issues (and their child issues) that are linked with with a "contributes to"- link to the Capability
- IF issuetype = Story or Bug AND the issue is linked to Capability (with a "contributes to"- link): : show only those issues that are linked with a "contributes to"- link to the Capability
Any ideas, on how to solve this? Thank you very much already in advance!