Make a quick vote 🗳 ️How do you refer to SuiteCRM extensions: add-ons or plug-ins? Click here to have your say 👈

Delete Logic Hook

It should work, but it doesn’t.
Thanks for your help

Before Delete Logic Hook
For this new scenario, the requirement is when an Account is deleted, all the contacts related to this accounts need to be deleted. In this ‘before_delete’ logic the code should fetch all the contact beans related to this account and mark the contacts as deleted.

Steps to create before delete hook
Logic needs to be triggered when an account is deleted. Create a logic hook in the below path.

   $hook_array['before_delete'][] = Array(
        'Delete related contact records',

Create a logic hook class in the below path

if (!defined('sugarEntry') || !sugarEntry)    die('Not A Valid Entry Point');

class delete_contacts {

    function delete_related_contacts($bean, $event, $arguments) {
        $arr_conIds[] = $bean->Contacts->get();
        foreach ($arr_conIds as $key => $id) {
           $contact_bean = BeanFactory::registerBean($id);