I have created following code to delete record from related module,when user click on a remove button.
I am facing a problem here that when i remove a single record it remove all the records from related module, instead of that single reocrd.
i am using “after_relationship_delete” logic hook.
try {
if (
isset($bean->rel_fields_before_value["cloud_lidmaatschap_con_contacten_1cloud_lidmaatschap_ida"]) &&
!empty($bean->rel_fields_before_value["cloud_lidmaatschap_con_contacten_1cloud_lidmaatschap_ida"])
) {
$contactpersonen_id = $bean->rel_fields_before_value["cloud_lidmaatschap_con_contacten_1cloud_lidmaatschap_ida"];
$contactpersonen = new cloud_Lidmaatschap();
$contactpersonen = $contactpersonen->retrieve($contactpersonen_id);
$contactpersonen->load_relationship('cloud_lidmaatschap_con_contacten_1');
$contactpersonen->cloud_lidmaatschap_con_contacten_1->delete($bean->id);
}
}
catch (Exception $ex) {
$GLOBALS['log']->fatal($ex->getMessage());
}