Workflow when unlinked relationship

Goodmorning,
I have a relationship (1:N) between Account and my custom module.
is there the possibility to create a workflow that intercept (and do something) when someone remove from subpanel into Account a relation to my custom module?

Thank you,
B.

I don’t think you can catch that in a Workflow (not 100% sure though)

You could do it easily with a after_relationship_delete logic hook.

Thank you for your reply.
Correct with after_relationship_delete it can works (I forgot this way). In this case, In which module I must define the logic hook? Accounts?

B.

I am not sure, I believe the hook fires in both, and it is even possible that it fires twice in each (at least many-to-many relationships, though that is not your case).

This is because some relationships are kept as two rows in the database (one from one X to Y, the other from Y to X).

My advice is to define both hooks, and check if they’re getting called more than once, at least to understand what’s going on, and keep an eye on the relationship table in the database. Eventually you might reach a simpler solution with a single hook.

thank you so much @pgr.
I tried with logic hook (after_relationship_delete) just in my custom module, and it works perfectly.
Thank you for your time and tips.
B.

1 Like