Need Help with JQL Query
Asked by PLaksh11:

We have 3 issue types

1.Bug

2. Root cause

3. Non Software

**Root cause** issue type will be linked with Both (Bug and Non Software) or (Bug or Non software)

Bug and Non software both has same issuelinktype "Causes" with Root cause.

**Now i want JQL which gives Root cause ticket which linked with "Bug" only.**

I tried below JQL but its giving both BUG and Non software which are linked with Root cause.

project = "Newhw" AND type = "Root cause" and issueLinkType="causes"

Is there any JQL which gives linked issue based on issuetype?


Answers:
author: Trudy Claspill
body: Hello [@PLaksh11](/t5/user/viewprofilepage/user-id/5542295)

That is not possible if you have only native Jira JQL functionality available to you.

It is possible with third party apps. Are you willing to consider getting an app that extends the capabilities of JQL?

comments: author: Prem
body: Hi [@Trudy Claspill](/t5/user/viewprofilepage/user-id/3569011) ,

Thanks for the clarification. But then it can be filtered out via **issuetype != "Non Software"**

Correct JQL - **Project = "Newhw" AND issuetype = "Root Cause" And issueLinkType = "causes" AND issuetype != "Non Software"**


author: PLaksh11
body: Hi [@Prem](/t5/user/viewprofilepage/user-id/5137550)

The Above Query is not working as per expectation. It still shows the Root cause ticket which has Non software.

Hi [@Trudy Claspill](/t5/user/viewprofilepage/user-id/3569011)

we are using Script runner enhanced Search is it possible to get through it?


author: Prem
body: Hi [@PLaksh11](/t5/user/viewprofilepage/user-id/5542295)

Can you share a screenshot of the query result, if possible?


author: Trudy Claspill
body: [@Prem](/t5/user/viewprofilepage/user-id/5137550)

No your modified query also does not work.

The criteria

**issuetype="Root Cause"**

...tells Jira you want only issues of type "Root Cause" in the results.

The criteria

**and issuetype != "Non Software"**

is not applied to the linked issues, which is what [@PLaksh11](/t5/user/viewprofilepage/user-id/5542295) is asking for.


author: Trudy Claspill
body: [@PLaksh11](/t5/user/viewprofilepage/user-id/5542295)

Yes, you can get what you want with ScriptRunner using the linkedIssuesOf() function.

<https://docs.adaptavist.com/sr4jc/latest/features/scriptrunner-enhanced-search/jql-functions#linkedissuesof>

project = "Newhw" AND type = "Root cause" and

issueFunction in linkedIssuesOf("project='Newhw' and issuetype='Bug' and issueLinkType='is caused by' ") and

not issueFunction in linkedIssuesOf("project='Newhw' and issuetype='Non Software' and issueLinkType='is caused by' ")

The first part says you want Root Cause issues.

The second part says you want only Root Cause issues that are part of the set of issues that are linked to Bug issues with the relationship 'Bug is caused by Root Cause'.

The third part says you want to exclude Root Cause issues that are part of the set of issues that are linked to Non Software issues with the relationship 'Non Software is caused by Root Cause'.


author: Prem
body: [@Trudy Claspill](/t5/user/viewprofilepage/user-id/3569011) - Thank you so much for corrections.


author: Hannes Obweger - JXL for Jira
body: Hi [@PLaksh11](/t5/user/viewprofilepage/user-id/5542295)

if you're open to solutions from the Atlassian Marketplace, your use case should be easy to solve using the app that my team and I are working on, [JXL for Jira](https://marketplace.atlassian.com/apps/1224710?hosting=cloud&tab=overview&utm_source=atlassian-community&utm_medium=referral&utm_content=2795438).

JXL is a full-fledged spreadsheet/table view for your issues that allows viewing, inline-editing, sorting, and filtering by all your issue fields, much like you'd do in e.g. Excel or Google Sheets. It also comes with a number of so-called *smart columns* that aren't natively available, including the *linked issue types*. You can easily filter your issues by these smart columns, like so:

![linked-issue-type-filtering.gif](https://community.atlassian.com/t5/image/serverpage/image-id/344577iDF113DCE308179F3/image-size/large?v=v2&px=999 "linked-issue-type-filtering.gif")

Once you've narrowed down your list of issues, you can work on your issues directly in JXL, trigger various operations in Jira, or export your issues with just one click.

I should add that JXL can do much more than that: From support for configurable *issue hierarchies* , to *issue grouping* by any issue field(s), *sum-ups* , or *conditional formatting*.

Any questions just let me know,

Best,

Hannes


author: Prem
body: Hi [@PLaksh11](/t5/user/viewprofilepage/user-id/5542295)

As far as I am understanding your query. This is what you should try.

JQL -  
**Project = "Newhw" AND issuetype = "Route Cause" AND issueLinkType = "causes" AND issuetype != "Non Software"**

comments: author: Trudy Claspill
body: Hello [@Prem](/t5/user/viewprofilepage/user-id/5137550)

Your answer is not correct.

[@PLaksh11](/t5/user/viewprofilepage/user-id/5542295) asked to get a list of only the Root Cause issues that are linked to only Bug issues. Your JQL will provide Root Cause issues linked to any type of issue with the "causes" link.


author: Prem
body: Thanks [@Trudy Claspill](/t5/user/viewprofilepage/user-id/3569011) Have made the necessary corrections.


Tags: cloud

jira-cloud