AnsweredAssumed Answered

after_relationship_delete logic hook deleting all records.

Question asked by usman khalid on Aug 30, 2018
Latest reply on Aug 30, 2018 by usman khalid

I have created following code to delete record from related module,when user click on a remove button, from subpanel.
I am facing a problem that when i remove a single record, it remove all the records from related module, instead of that single record.
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());
        }

Outcomes