after_relationship_delete and one-to-one relationship

Hi, i’m developing a module with this crm. I have a BIG problem.
I have a relationship one to one (mymodule->users), then when I delete relationship will be called after_relationship_delete logic hook. Ok work fine. But if I change relationship from myModule->user1 to myModule->user2 after_relationship_delete will be called anyway. How can i know when is a change of relationship and when i can know that is a delete (user->null relationship)?
thx in advances

I’m not sure of the answer… but maybe this will help you

Those arguments must have some difference in the two cases you need to distinguish.

hi., thx for reply. But i have this situation:

1- myModule->user1
2- delete myModule->user1 relationship 
3- after_relationship_delete is called (ok, fine, it works)

But if i change relationship how do i check that is a “edit” and not a delete?

1- myModule->user1
2- i change user1 to user2 (relationship one-to-one)
3- suitecrm remove myModule->user1 relationship
4- after_relationship_delete is called
5- add myModule->user2 relationship

How avoid call the point 4?

The idea was that you check the $arguments in point 4 and see if you can find a difference (in the related records) to the other case. You don’t avoid it being called, you just try to see difference so you can put your code inside an “if” and only execute in the case you want.

i have comparated arguments (in both of case) they are identical

I asked a developer and he said

Don’t ask me to explain, just try to understand it yourself :slight_smile:

1 Like

[quote=“pgr” post=63233]I asked a developer and he said

ok, thx
I’ve used after_rel_delete, then in after_rel_add I check if is a change of relationship (if $arguments[‘related_bean’]->ida_relationship != bean->id, if true it is a change of relationship)
Work fine in this way.
Only in after_relationship_add is possible check, in after_relationship_delete no.

1 Like