JQL query to find all the child issues for a given parent whose custom field matches withe custom field of parent issue

How can we write a jql query to find all the child issues for a structure whose custom field named area(example) matches with the custom field named area of the parent issue?

i have the following structure query to get all the child issues for a given parent issue. But how to add the extra part in the query to retrieve only those issues which are having the same value for a particular custom field like its parent?

issue in structure(Hierarchy, "descendant of PROJ-980")

 

 

2 answers

1 accepted

This widget could not be displayed.

if PROJ-980 has area X, you can say 

issue in structure(Hierarchy, "descendant of PROJ-980 and [area = X]")

Note, however, that in either S-JQL or in JQL you cannot express constrains on issues based on field values of other issues; you always need to name values directly. When designing S-JQL, we thought about including such constraints, but we decided not to because we lacked evidence that someone will need it. So far this is the first request of this kind.

As a workaround, if the field can have one of a few values, you can enumerate these values. For example, suppose that field area can only have three values: X, Y and Z; then you say

issue in structure(Hierarchy, "[area = X] and descendant of [area = X] OR
[area = Y] and descendant of [area = Y] OR
[area = Z] and descendant of [area = Z]
")

In case you need to find all descendants whose area > parents area, again, you'll need to name parent values directly:

issue in structure(Hierarchy, "[area > X] and descendant of [area = X] OR
[area > Y] and descendant of [area = Y] OR
[area > Z] and descendant of [area = Z]")

Edit: I've created a request in our JIRA for extending S-JQL to allow the mentioned constraints.


This widget could not be displayed.

Thanks Igor that was very helpful. To add to the above query can we also perform search like this

in case i have a parent issue in structure of type "parent" and there are 4 subissues/descendants under it of type "sub" . Each of these issues have some area defined. i need to search all the subissues/descendants  whose area is greater than parent's area

so something like " find all descendants whose area > parents area"

Can we search in the existing S-JQL?

 

I can understand from your comments "Note, however, that in either S-JQL or in JQL you cannot express constrains on issues based on field values of other issues; you always need to name values directly" but in case if we need to incorporate such criteria how can we do that?

Again, you'll need to name the parent's area directly. So, if field {{area}} can only have values {{X, Y}} and {{Z}}, you'll need to do this: issue in structure(Hierarchy, "[area > X] and descendant of [area = X] OR [area > Y] and descendant of [area = Y] OR [area > Z] and descendant of [area = Z]")

I've edited my answer to include this comment.

Thanks Igor . Thanks a ton. That helped me. I have created few issues assigned the area and some of these issues are descendants of issue1 (descendant1,descendant2) and issue2 (descendant3,descendant4). Both issue1 and issue2 has area 10. So my query is: issue in structure("structure - 1" , " [area>10] and descendant of [area=10] ") So in case all these descendants have area > 10 , all the issues will be pulled out since both the parent issue had area 10. But if i want to restrict it to only one parent: issue in structure("structure - 1" , " [area>10] and descendant of [area=10] ") and and issue in structure(" structure - 1 ", "descendant of TESTNEW-785") This would work. But is there a better way of doing this.(restricting to some particular parent)

Sure — you just need to substitute area constraint to issue key constraint: issue in structure("structure - 1", "[area > 10] and descendant of TESTNEW-785")

Thank you Igor :)

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Aug 22, 2018 in Marketplace Apps

How a Marketplace app tech team is achieving gender diversity

Hello! My name is Genevieve Blanch, and I'm the Marketing Manager at RefinedWiki, creators of apps to give teams the tools to customize Atlassian platforms. Currently, 44% of the tech team at Re...

510 views 3 18
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you