# How to get info from all parent groups? (multi-layered)

**URL:** <https://community.novulo.com/t/how-to-get-info-from-all-parent-groups-multi-layered/56>\
**Category:** \[Q&A\] Developer Tools\
**Tags:** architect\
**Created:** [March 28, 2024, 11:39am UTC](https://community.novulo.com/t/how-to-get-info-from-all-parent-groups-multi-layered/56 "2024-03-28T11:39:50Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Yori](https://yyz2.discourse-cdn.com/flex008/user_avatar/community.novulo.com/yori/32/12_2.png) [@Yori](https://community.novulo.com/u/Yori)\
**Post date:** [March 28, 2024, 11:39am UTC](https://community.novulo.com/t/how-to-get-info-from-all-parent-groups-multi-layered/56/1 "2024-03-28T11:39:50Z")

</div>

- Productgroup 1
- 
  - Productgroup 1.1

- 
  - Productgroup 1.2

- 
  - Productgroup 1.3

- 
  - 
    - Productgroup 1.3.1

- 
  - 
    - Productgroup 1.3.2

- 
  - 
    - Productgroup 1.3.3

- 
  - 
    - 
      - Productgroup 1.3.3.1

- 
  - Productgroup 1.4

Each layer of the Productgroups has QuestionConnections.  
A Questionconnection is a connection between a Productgroup and a Question…  
Questionconnections are stored per layer 1, 2, 3 and 4.

Question: With which expression can I get the list of all parent Questionconnections from a certain Productgroup?

So Product X has Productgroup 1.3.3.1. How to get all Questionconnections from this group + all parent groups?  
(Ideally independend of the layer, but otherwise context can always be the 4th layer)

---

<div class="post-metadata">

**Author:** ![Redmer](https://yyz2.discourse-cdn.com/flex008/user_avatar/community.novulo.com/redmer/32/3_2.png) [@Redmer](https://community.novulo.com/u/Redmer)\
**Post date:** [March 28, 2024, 12:05pm UTC](https://community.novulo.com/t/how-to-get-info-from-all-parent-groups-multi-layered/56/2 "2024-03-28T12:05:32Z")

</div>

I think this sould work. The context of the expression is the questionconnection record of productgroup 1.3.3.1.

```auto
{
 questionconnections,
 this,
 boolean:or([
  productgroup.equals(parent),
  int:exists({
   questionconnections,
   1,
   boolean:or([
    parent.parent.parent_group.equals(this.productgroup),
    parent.parent.parent_group.parent_group.equals(this.productgroup),
    parent.parent.parent_group.parent_group.parent_group.equals(this.productgroup)
   ])
  })
 ])
}

```

I havent tested this. Should test performance with all those OR statements 🙂

---

<div class="post-metadata">

**Author:** ![Joost](https://yyz2.discourse-cdn.com/flex008/user_avatar/community.novulo.com/joost/32/87_2.png) [@Joost](https://community.novulo.com/u/Joost)\
**Post date:** [March 28, 2024, 1:33pm UTC](https://community.novulo.com/t/how-to-get-info-from-all-parent-groups-multi-layered/56/3 "2024-03-28T13:33:57Z")

</div>

Hi Yori,  
Check M3844 Novulo Afdelingen.  
Here, I implemented full logic to support this. It’s a method that can easily be implemented in Productgroepen as well. I’d say you can do this in 2-4 hours by just having the two screens next to each other.

Redmer’s solution is limited in levels and won’t perform in big implementations

---

<div class="post-metadata">

**Author:** ![Martijn](https://avatars.discourse-cdn.com/v4/letter/m/dbc845/32.png) [@Martijn](https://community.novulo.com/u/Martijn)\
**Post date:** [March 29, 2024, 9:24am UTC](https://community.novulo.com/t/how-to-get-info-from-all-parent-groups-multi-layered/56/4 "2024-03-29T09:24:32Z")

</div>

Hi Yori, in your scenario (i.e. the product is linked to the lowest level product group) the fx root version @ systemversions in component 4207 could also be an inspiration for your question. This function is recursive but because it’s cached it will work.

---

<div class="post-metadata">

**Author:** ![j.batzke](https://yyz2.discourse-cdn.com/flex008/user_avatar/community.novulo.com/j.batzke/32/9_2.png) [@j.batzke](https://community.novulo.com/u/j.batzke)\
**Post date:** [March 29, 2024, 12:19pm UTC](https://community.novulo.com/t/how-to-get-info-from-all-parent-groups-multi-layered/56/5 "2024-03-29T12:19:54Z")

</div>

Hey Yori,  
yesterday I came across component M5935 which also has an interesting recursive function in it to retrieve the warehouse of a stock location category which can be nested indefinably as well.  
It might inspire you for your solution. The key is to have some sort of stop condition I guess (e.g: the parent\_group is not set)

If you are not limited to an expression, you might want to build a process that adds all QuestionConnections of a group to a list and restarts over with the parent group as long as the parent is set.  
Something like this:

 ![image](https://canada1.discourse-cdn.com/flex008/uploads/novulo/original/1X/0dcf38d5634872e4a8a34482c4213420ecabfd21.png)
