Hi,
I have this problem:
in my custom module I inserted a relationship with another custom module, doing some tests, I discovered that after creating a record directly from the subpanel, when I delete it using the remove button, the record is deleted from the subpanel, but if I go to the module of the relationship, the record is still present.
Does anyone know why and how to fix it?
Thanks
By design, removing from a subpanel only removes the relationship to the current record, not the related record itself.
You can probably make an after_delete_relationship logic hook to also delete the target record, if that’s always what you want.
In other modules, always custom, but not created by me, if I delete a record from a subpanel, it also deletes the record of the related module and there is no logic hook after delete. Is there a setting in the Studio?
Otherwise how do I manage it via logic hook? Do you have an example?
Even if doing it this way, manually it seems absurd to me
If they are custom modules, I don’t know what else is there…
- a Workflow perhaps?
- custom classes overriding code?
Did you check non-custom modules? Does it work as I said? I just want to make sure we’re seeing the same thing.
Ok, I tried to do as you say.
In Account I created a new activity (in the subpanel) and then I deleted it, as you said, it was deleted in the subpanel, but it remained in the activity module.
Ok, so to delete it also from the module it must be managed exclusively through the logic hook? Isn’t there any particular setting? In the Studio? In Vardefs? In Layoutdefs?
I am trying to delete the record via logic_hook, but I have noticed that the before_delete is not considered.
I inserted the logic_hook in the module of the record to be deleted (subpanel of the main module), the before_delete is called only if I delete the record directly from the module and not from the subpanel.
Any ideas, please?
it’s possible that something like this exists, but I don’t know about it, sorry
The hook you want is after_relationship_delete on the parent module, on the one you are at, when seeing the subpanel.
I solved, via logic_hook (after_relationship_delete), put in the second module (the subpanel) and from here then:
$bean = BeanFactory::getBean('<SUBPANEL MODULE>', $bean->id);
$bean->deleted = 1;
$bean->save ();