# Unable to display fields generated by afterFind Sequelize Hook in Relationship

**URL:** <https://community.forestadmin.com/t/unable-to-display-fields-generated-by-afterfind-sequelize-hook-in-relationship/3754>\
**Category:** Help me!\
**Created:** [November 23, 2021, 9:16am UTC](https://community.forestadmin.com/t/unable-to-display-fields-generated-by-afterfind-sequelize-hook-in-relationship/3754 "2021-11-23T09:16:41Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![paulclavier](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/paulclavier/32/3592_2.png) [@paulclavier](https://community.forestadmin.com/u/paulclavier)\
**Post date:** [November 23, 2021, 9:16am UTC](https://community.forestadmin.com/t/unable-to-display-fields-generated-by-afterfind-sequelize-hook-in-relationship/3754/1 "2021-11-23T09:16:42Z")

</div>

## Feature(s) impacted

I have this data model:  
`Shareholder: 1--N :ShareholderDocument: 1--1 :Document`

ShareholderDocument only contains an `id`, `shareholderId` and `documentId`, while Document model has more information like contentType, documentType, status etc.

In my view Shareholder, I would to see its list of documents with all the infos (contentType, documentType, status etc).  
I created in my sequelize ShareholderDocumentModel a hook `afterFind` to retrieve these fields:

 ![Capture d’écran 2021-11-23 à 10.02.34](https://europe1.discourse-cdn.com/flex013/uploads/forest/original/2X/c/c954799d1327b8dda5fed76eb00bc009493e2502.png)

## Observed behavior

When I go to my dashboard, on a Shareholder, I see the following:

 ![Capture d’écran 2021-11-23 à 10.13.16](https://europe1.discourse-cdn.com/flex013/uploads/forest/original/2X/3/3af9d20a884b93b8b9d7eecf89e8a025de4add50.png)  
You can see on the bottom right that all fields related to Document are blank (contentType, documentType, status etc). I guess this is due to [this issue from Sequelize](https://github.com/sequelize/sequelize/issues/4627)

## Expected behavior

I am expecting to see all fields filled like this (caught from the ShareholderDocument view, where all fields are correctly fetched -given its not fetched using a relationship (cf issue mentionned above)-)

 ![Capture d’écran 2021-11-23 à 10.14.48](https://europe1.discourse-cdn.com/flex013/uploads/forest/original/2X/8/886b537f74ecf284017fbb7e92f4430f0bf18e22.png)

## Context

The environnement is local

## Strategy

I understand given the issue mntionned above, what I want to do using sequelize hooks might be impossible.  
My question instead would be:

- Should I use Forest Hooks ?
- Should I use smartFields ?
- Should I use a smartRelationship with DocumentModel directly ? (we would like to avoid it)

Thank you for your help 🙂

---

<div class="post-metadata">

**Author:** ![anon34731316](https://avatars.discourse-cdn.com/v4/letter/a/eada6e/32.png) [@anon34731316](https://community.forestadmin.com/u/anon34731316)\
**Post date:** [November 23, 2021, 11:29am UTC](https://community.forestadmin.com/t/unable-to-display-fields-generated-by-afterfind-sequelize-hook-in-relationship/3754/2 "2021-11-23T11:29:51Z")

</div>

Hello @paulclavier,

Thank you for your message 🙌

After having reading your use case, I have a small question: why not defining a new association in your Shareholder’s model that refers directly to Document through the join table (ShareholderDocument)?  
Did you try that (here is some Sequelize [documentation](https://sequelize.org/master/manual/advanced-many-to-many.html) about it)?

If it works for you, in the UI, in the Shareholder related data you could just display the Documents and hide ShareholderDocuments.

Let me know!  
Thanks.

---

<div class="post-metadata">

**Author:** ![paulclavier](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/paulclavier/32/3592_2.png) [@paulclavier](https://community.forestadmin.com/u/paulclavier)\
**Post date:** [November 25, 2021, 9:12am UTC](https://community.forestadmin.com/t/unable-to-display-fields-generated-by-afterfind-sequelize-hook-in-relationship/3754/3 "2021-11-25T09:12:22Z")

</div>

Hey @anon34731316 ,

Thank you for your reply.  
We did consider this choice at first but we have ShareholderDocument and also multiple tables for different document owners like OtherTypeOfOwnerDocument let’s say.  
We want to maybe apply different business rules in the models for each type of owner.

However we did manage to cope with our issue 🙂  
We used Sequelize hooks `afterFind` to enrich our ShareholderDocument with Document information.  
Then we defined a smartRelationship between our Shareholder and ShareholderDocument (Sequelize fetching directly thus with hooks activated)  
It works nicely.
