Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

How to extract parent issue by filtering with a child field

Amrutha December 4, 2020

Hi,

 

How can we extract parent issue along with the child issue based on filtering the child filed & it's value.

 

Example: https://base/rest/api/3/search?fields=summary, customfield_10261, subtasks, parent & jql=project='EVENT'+and+issuetype+in+('Event','CalendarEntry')+and+cf[10262]>="2020-12-15 00:00"

 

- Parent issue is Event & child issue is CalendarEntry

- cf[10262] is a child issue field.

- The above API returns only the sub issues that is CalendarEntry. But I want to extract their parent issue also along with the response.

1 answer

0 votes
Warren
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 7, 2020

Hi @Amrutha 

The reason why you're only getting child issues is because of the cf[10262] bit - it doesn't exist for any parent issues, so it won't return them. What you would need to do is adjust your JQL to look like

and (cf[10262]>="2020-12-15 00:00" or cf[10262] is EMPTY)

so that it will pick up parent issues that match the rest of your query

Amrutha December 7, 2020

Hi @Warren ,

 

thank you for the above solution. 

 

Yes, it works! but it will return other parent issues also. How can I filter unwanted parent issues?

Warren
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 7, 2020

Hi @Amrutha 

I'm not sure I can easily help you with that, because you know your boards and data, I don't.

I'm not aware of a function that's standard to Jira which can find only parents of the children returned in the same query.

Is there some distinguishing data in the parents that you could filter on?

Otherwise, once the query has run, you can sort on different columns which may be able to help you a bit.

Amrutha December 7, 2020

Hi @Warren

 

Please find the attachment for the result. 

So, I want to list only sub-task issue (that matches customfield value) & it's parent issue but exclude other parent issues which are listing for the "EMPTY" condition.

Amrutha December 7, 2020

Screenshot 2020-12-07 at 4.11.55 PM.png

Warren
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 7, 2020

Hi @Amrutha 

I understand what you're wanting to list, but as I said above, there isn't a standard Jira function to list parents of only the children reported in a query.

If this is a one-off check, you would probably need to just spend some time doing some manual checks.

If this is something that you're wanting to do regularly, if you're able to, I would recommend looking into using the REST API and some code (javascript, C#, VB, Excel VBA). That way, the first pass can get you all the children (with their associated parent keys) and the second pass can get the details of each of those parents.

Another option would be to get a paid add-on (something like ScriptRunner) which potentially could have a function to return parents of children

Amrutha December 7, 2020

Thanks @Warren :) 

Suggest an answer

Log in or Sign up to answer