# Display data via smart relationship based on two relationship

**URL:** <https://community.forestadmin.com/t/display-data-via-smart-relationship-based-on-two-relationship/6159>\
**Category:** Help me!\
**Created:** [April 5, 2023, 4:04pm UTC](https://community.forestadmin.com/t/display-data-via-smart-relationship-based-on-two-relationship/6159 "2023-04-05T16:04:08Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![mduhez](https://avatars.discourse-cdn.com/v4/letter/m/4af34b/32.png) [@mduhez](https://community.forestadmin.com/u/mduhez)\
**Post date:** [April 5, 2023, 4:04pm UTC](https://community.forestadmin.com/t/display-data-via-smart-relationship-based-on-two-relationship/6159/1 "2023-04-05T16:04:08Z")

</div>

## Feature(s) impacted

smart relationship

## Observed behavior

We have this structure :  
a place has multiple diagnoses  
a place has multiple diagnoses\_categories  
a diagnoses has one diagnoses\_categories  
a diagnoses\_categories has multiple diagnoses

On places collection we display diagnoses\_categories has a related data and in diagnoses\_categories collection we display all diagnosis has smart relationship

When going through places collections and her diagnoses\_categories we want to display only the diagnoses related to diagnoses\_categories and places

For now we know how to get the diagnoses\_categories id (via request.params.id) but we are unable to get the places id. Is there a solution to this problem ?

## Expected behavior

We can display our data based on two params : the direct relationship and another data which come from naviguation

thank you

## Failure Logs

## Context

- Project name: sergic
- Team name: gestion
- Environment name: recette
- Database type: postgresql

---

<div class="post-metadata">

**Author:** ![Arnaud\_Moncel](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/arnaud_moncel/32/24_2.png) [@Arnaud\_Moncel](https://community.forestadmin.com/u/Arnaud_Moncel)\
**Post date:** [April 6, 2023, 2:27pm UTC](https://community.forestadmin.com/t/display-data-via-smart-relationship-based-on-two-relationship/6159/2 "2023-04-06T14:27:10Z")

</div>

Hi @mduhez 👋 unfortunately what you asking for does not exist yet. I will push your request on our product board.  
In order to try to find a workaround can you give us more details about your database schema please 🙏

---

<div class="post-metadata">

**Author:** ![mduhez](https://avatars.discourse-cdn.com/v4/letter/m/4af34b/32.png) [@mduhez](https://community.forestadmin.com/u/mduhez)\
**Post date:** [April 7, 2023, 7:37am UTC](https://community.forestadmin.com/t/display-data-via-smart-relationship-based-on-two-relationship/6159/3 "2023-04-07T07:37:17Z")

</div>

Thank you for your response

What we need :

collection places → related data diagnoses\_categories (filtered by places\_id, no problem) → smart relationship diagnoses (filtrered by categories\_id and places\_id, there is a problem with the places\_id)

The database schema is slightly different from what I had in mind:

- Diagnoses has a foreign key to on diagnoses\_category and to one place
- In place there is a smart field for diagnoses\_category\_id but no link in database, we use a smart relationship to retrieve all the categories via a findAll request
- in diagnoses\_categories routes, we create a smartrelationship which use diagnoses\_category\_id to retrieve diagnoses - this is where we need a place id to retrieve correct data

---

<div class="post-metadata">

**Author:** ![Arnaud\_Moncel](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/arnaud_moncel/32/24_2.png) [@Arnaud\_Moncel](https://community.forestadmin.com/u/Arnaud_Moncel)\
**Post date:** [April 12, 2023, 7:54am UTC](https://community.forestadmin.com/t/display-data-via-smart-relationship-based-on-two-relationship/6159/4 "2023-04-12T07:54:27Z")

</div>

Hi @mduhez 👋 thank you for your precision, it will help for the future.  
Unfortunately I can’t see any workaround.  
As I said, your request is pushed to our product board.  
Thank you again for you feedback.
