Forums

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

Enhanced Search Grandparent Filter or Custom Field?

Gaetano Antonio Turturro April 28, 2025

Hi community,
I'm trying to create a filter that returns the parent of the parent of a generic issue or work item, depending on the terminology used.

At the moment, I have thought of two approaches:

Populate a custom field "grandparent" using a Script Listener.

Use Enhanced Search leveraging the parentOf() function. However, I have some doubts about this second option:

Regarding the second parameter of the parentOf() function: it seems you should specify the degree of parentage, but the only available option appears to be all (even after performing a full reindex). Could you please explain better how this parameter works?

If I save the filter and share it with other users, will the query remain editable? I would like to know if it is possible to dynamically change the issuekey in the query to search for the "grandparent" of other issues, without having to create a new filter each time.

Thanks in advance for your help!

---------------------------------------------------------------------------------------

Ciao community,
sto cercando di creare un filtro che restituisca il parent del parent di una generica issue o work item, a seconda della terminologia utilizzata.

Al momento ho pensato a due approcci:

Popolare un custom field "grandparent" tramite uno Script Listener.

Utilizzare Enhanced Search sfruttando la funzione parentOf(). Su questa seconda possibilità però ho alcuni dubbi:

Riguardo il secondo parametro della funzione parentOf(): si dovrebbe specificare il grado di parentela, ma sembra che l'unica opzione disponibile sia all (nonostante io abbia effettuato la sincronizzazione completa). Potete spiegarmi meglio il funzionamento di questo parametro?

Se salvo il filtro e lo condivido con altri utenti, la query rimane modificabile? Mi interessa sapere se è possibile sostituire dinamicamente l'issuekey nella query per cercare i "grandparent" di altre issue, senza dover creare ogni volta un nuovo filtro.

Grazie in anticipo per l'aiuto!

 

1 answer

Suggest an answer

Log in or Sign up to answer
1 vote
Trudy Claspill
Community Champion
April 28, 2025

Hello @Gaetano Antonio Turturro 

Regarding the second parameter of the ScriptRunner parentsOf() function, there are only two options:

1. get just the immediate parent issue of the issues described in the subquery.

2. get all the ancestors (parent, grandparent, great-grandparent, etc.) of the issues described in the subquery

It is not possible to specify a specific level in the hierarchy, such as grandparent.

You could create an Enhanced Search filter to get the direct parents of the issues. Save that filter, and then use that filter as the subquery of another parentsOf() filter.

Example:

filter1 = issuefunction in parentsOf("Project=ABC and type=Story")

filter2 = issuefunction in parentsOf("filter=filter1")

Gaetano Antonio Turturro April 29, 2025

Hi @Trudy Claspill , this solution definitely works and I thank you for it, but it doesn’t seem very "clean" to me.
On the other hand, the custom field feels like an unnecessary burden, so I think I'll go with the first option.
This way, if the user wants to modify the filter to retrieve the grandparents of a different issue, they will need to adjust the first "subfilter" and then move to the second filter.
Let me know if I misunderstood anything.

Gaetano Antonio Turturro April 30, 2025

or some reason, it’s not working as expected. I've come up with a new strategy using ScriptRunner:

Add a workflow action (a transition that loops back to the same status) which dynamically updates a filter to show only the grandparent of the current issue.
Screenshot 2025-04-30 104427.pngScreenshot 2025-04-30 104627.pngScreenshot 2025-04-30 104537.png
I'm sending you the screenshots that show the Enhanced Search, as configured following your suggestion, is returning no results.

 

Trudy Claspill
Community Champion
April 30, 2025

Your "parent" filter shows that one issue was found (XR2J-6) that is a Parent of issues in the specified project.

  1. What type of issue is XR2J-6?
  2. Is that an accurate result, or do you think more issues should be returned?

Your "grandparent" filter shows no results.

  1. Does XR2J-6 have a value in its Parent field?

The issue image you provided doesn't include the key of the issue being viewed.

  1. Is that XR2J-6?

What type of project are you working with? Get that information from the Type column on the View All Projects page under the Projects menu.

Are all the issues in the hierarchy in the same project?

Trudy Claspill
Community Champion
May 2, 2025

Hello @Gaetano Antonio Turturro 

Are you interested in debugging what is happening with the nested ScriptRunner filters? If so, can you provide the information I requested in my previous response?

Gaetano Antonio Turturro May 5, 2025

Hello @Trudy Claspill , and sorry for the delay

  1. XR2J-6 is a sub-task.
  2. The parent issue appears correctly in the search results, unlike the grandparent.
  3. The hierarchy is:
    Sub-task (child: XR2J-6) → Task (parent: XR2J-5) → Epic (grandparent: XR2J-3).
  4. The issue you're looking at is the parent task (XR2J-5).
  5. This is a Software Project – Kanban – Company Managed,
  6. and of course, all the issues belong to the same project.
Trudy Claspill
Community Champion
May 6, 2025

Do you have any hierarchy levels above Epic?

I had the same experience when I replicated this in a project that has just the three hierarchy levels.

Reviewing the documentation for parentsOf()

https://docs.adaptavist.com/sr4jc/latest/features/scriptrunner-enhanced-search/scriptrunner-enhanced-search-jql-functions/links-and-relationships#parentsof

... it seems that if you don't include the option "all" parameter then the results are only the parents of subtasks that match your filter. It does not return parents for any other issue type at a different hierarchy level in that case.

So in your case you would need to use this type of filter to get the Epics:

issuefunction in parentsOf("project=YourProjectName", "all") and type=Epic

That would get you all the ancestors of the subtasks, and then reduce that list to only the ones that have an issue type of Epic.

DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
PREMIUM
PERMISSIONS LEVEL
Product Admin
TAGS
AUG Leaders

Atlassian Community Events