# Retrieve parent from navigation and filter grand children data

**URL:** <https://community.forestadmin.com/t/retrieve-parent-from-navigation-and-filter-grand-children-data/2312>\
**Category:** Help me!\
**Created:** [April 14, 2021, 8:18am UTC](https://community.forestadmin.com/t/retrieve-parent-from-navigation-and-filter-grand-children-data/2312 "2021-04-14T08:18:19Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![JeremyV](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/jeremyv/32/1033_2.png) [@JeremyV](https://community.forestadmin.com/u/JeremyV)\
**Post date:** [April 14, 2021, 8:18am UTC](https://community.forestadmin.com/t/retrieve-parent-from-navigation-and-filter-grand-children-data/2312/1 "2021-04-14T08:18:19Z")

</div>

I have 3 models :

places

```javascript
Places.hasMany(models.maintenanceContracts, {
      foreignKey: {
        name: 'placeIdKey',
        field: 'place_id',
      },
      as: 'maintenanceContracts',
    });

```

maintenanceContracts

```javascript
MaintenanceContracts.belongsTo(models.maintenanceContractCategories, {
      foreignKey: {
        name: 'maintenanceContractCategoryIdKey',
        field: 'maintenance_contract_category_id',
      },
      as: 'maintenanceContractCategory',
    });

```

maintenanceContractsCategories

```javascript
MaintenanceContractCategories.hasMany(models.maintenanceContracts, {
      foreignKey: {
        name: 'maintenanceContractCategoryIdKey',
        field: 'maintenance_contract_category_id',
      },
      as: 'maintenanceContractCategoryMaintenanceContracts',
    });

```

I’ve created a smart relationship in forest/places

```javascript
  {
    field: 'categories',
    type: ['String'],
    reference: 'maintenanceContractCategories.id'
  }

```

In a nutshell, it is place =\> maintenanceContracts =\> maintenanceContractCategories and it works

In Forest Admin I display a place summary view ; i have in related data its categories, for instance :

 ![image](https://europe1.discourse-cdn.com/flex013/uploads/forest/original/2X/e/edc2e4a173437527bc8478238d8aaa424721f8bf.png)

When I display the category summary view, I find all related maintenanceContracts.

 ![image](https://europe1.discourse-cdn.com/flex013/uploads/forest/original/2X/f/f29e78610e32533a6096120dc9771e069e53ffef.png)

I would like to see the “place where i’m coming from” related maintenanceContracts ONLY, but from this screen I have no idea how I can filter this maintenanceContracts list.

Can you help me for this ?

---

<div class="post-metadata">

**Author:** ![anon39848301](https://avatars.discourse-cdn.com/v4/letter/a/b9e5f3/32.png) [@anon39848301](https://community.forestadmin.com/u/anon39848301)\
**Post date:** [April 14, 2021, 2:11pm UTC](https://community.forestadmin.com/t/retrieve-parent-from-navigation-and-filter-grand-children-data/2312/2 "2021-04-14T14:11:07Z")

</div>

Hi @JeremyV,

Filtering related data is a recent feature, introduced for `forest-express-sequelize/mongoose@7.3.0` & `forest_liana@4.0.0`, but will not currently allow to filter using navigation/grand children context. It could be useful here still since it would allow you to manually filter the result you are getting in your related data.

I’m pushing this on our product board 🙌

---

<div class="post-metadata">

**Author:** ![JeremyV](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/jeremyv/32/1033_2.png) [@JeremyV](https://community.forestadmin.com/u/JeremyV)\
**Post date:** [April 14, 2021, 2:14pm UTC](https://community.forestadmin.com/t/retrieve-parent-from-navigation-and-filter-grand-children-data/2312/3 "2021-04-14T14:14:50Z")

</div>

Thank you @anon39848301  
Is there any way I could know in which place I am currently ? so i can build a smart field which displays the current maintenance contract.

---

<div class="post-metadata">

**Author:** ![anon62739609](https://avatars.discourse-cdn.com/v4/letter/a/c2a13f/32.png) [@anon62739609](https://community.forestadmin.com/u/anon62739609)\
**Post date:** [April 19, 2021, 9:16am UTC](https://community.forestadmin.com/t/retrieve-parent-from-navigation-and-filter-grand-children-data/2312/4 "2021-04-19T09:16:16Z")

</div>

Hey @JeremyV,

I’m not sure to understand your question 😅 . Could you clarify it a little bit 🙏 ?

---

<div class="post-metadata">

**Author:** ![JeremyV](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/jeremyv/32/1033_2.png) [@JeremyV](https://community.forestadmin.com/u/JeremyV)\
**Post date:** [April 19, 2021, 9:49am UTC](https://community.forestadmin.com/t/retrieve-parent-from-navigation-and-filter-grand-children-data/2312/5 "2021-04-19T09:49:03Z")

</div>

@anon62739609

It has evolved a bit since, so let me rephrase it :

From the place collection, I display a place summary view.  
I created a categories smart relationship. So I click on “Categories” and it displays categories for this place.  
Note that there is no real relationship in DB between a place and a category.

THEN, I click on one Category ; it displays the category summary view.  
There, I need to display the list of contracts for this category and **for the place I’m coming from**.

Since, as i stated before, there is no real relationship between category and place, i have no “placeIdKey” in the category record.

BUT, in the breadcrumb, I have the path displaying the place from where I am coming.

So if I had to build a smart relationship for the categories collection, how can I know in this NodeJS smart relationship route the placeID i displayed in my first screen.

Because I have to display the contracts for this category and this place.

---

<div class="post-metadata">

**Author:** ![anon62739609](https://avatars.discourse-cdn.com/v4/letter/a/c2a13f/32.png) [@anon62739609](https://community.forestadmin.com/u/anon62739609)\
**Post date:** [April 19, 2021, 1:05pm UTC](https://community.forestadmin.com/t/retrieve-parent-from-navigation-and-filter-grand-children-data/2312/6 "2021-04-19T13:05:40Z")

</div>

Right now you can’t. I’ll push your feedback to product board 😉
