# Set hook on relations

**URL:** <https://community.forestadmin.com/t/set-hook-on-relations/5551>\
**Category:** Help me!\
**Created:** [November 20, 2022, 8:20pm UTC](https://community.forestadmin.com/t/set-hook-on-relations/5551 "2022-11-20T20:20:45Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![bond](https://avatars.discourse-cdn.com/v4/letter/b/9dc877/32.png) [@bond](https://community.forestadmin.com/u/bond)\
**Post date:** [November 20, 2022, 8:20pm UTC](https://community.forestadmin.com/t/set-hook-on-relations/5551/1 "2022-11-20T20:20:45Z")

</div>

How can I set a hook on relations?  
I need to do sth after adding/linking a relation record.  
I found `addHook` for collections but I couldn’t find anything which does the same for relations.

---

<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 21, 2022, 11:12am UTC](https://community.forestadmin.com/t/set-hook-on-relations/5551/2 "2022-11-21T11:12:25Z")

</div>

Hello @bond,

Thanks for your message 🙌

Could you please tell us a bit more on the context of this request?  
On what agent name and version are you working on?  
Could you please give us your project name as well?

Thank you.

---

<div class="post-metadata">

**Author:** ![bond](https://avatars.discourse-cdn.com/v4/letter/b/9dc877/32.png) [@bond](https://community.forestadmin.com/u/bond)\
**Post date:** [November 21, 2022, 1:37pm UTC](https://community.forestadmin.com/t/set-hook-on-relations/5551/3 "2022-11-21T13:37:01Z")

</div>

Hello,  
Thank you for your attention.  
Currently, we are using the forestadmin’s JS SDK@1.0.0-beta.55 on top of the NestJS framework.  
The project name is “Bond”.

---

<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:** [November 21, 2022, 1:46pm UTC](https://community.forestadmin.com/t/set-hook-on-relations/5551/4 "2022-11-21T13:46:23Z")

</div>

Hey @bond

`addHook` should work in your case if you set the hook the on targeted relation model.

You could also use `replaceFieldWriting` but we highly suggest to rely on hooks for those kind of feature.

Again, if you could share a use-case (either here or via DM if you consider it private), maybe we can be a bit more specific on how to implement such use-case.
