AnsweredAssumed Answered

How to solve after_relationship_add logic hooks for 1-1 relationship?

Question asked by Doddy Amijaya on Jun 26, 2017
Latest reply on Jul 6, 2017 by Doddy Amijaya

Here is the picture...

I have module called Peanuts and elephant. the relationship is 1 to 1.

both modules have the same related records under it call A, B and C.

 

The scenario that  I have are the following:

if I am in Peanuts Module and I link an elephant, it should transfer (linked) the related records A, B and C TO Elephants module.

but if I am in Elephant Module and I link a peanut it should linked the related records the other way around.

 

I tried to use after_relationship_add to achieve this however as we all know, after_relationship_add will be ran in both modules. so what I ended up happening, when I am in Elephant modules and I link a Peanut module, it links Elephant related module to Peanuts AND it also link Peanut related records to Elephant.

 

I have looked and looked to find a way to distinguish where the logic hooks originally fired but I couldn't tell.

none of the $events or $arguments value can tell me that.

 

is this doable?

Outcomes