AnsweredAssumed Answered

Sugar 7 - Prevent certain records from being deleted

Question asked by jjackson_deactivated on Dec 16, 2015
Latest reply on Dec 17, 2015 by jjackson_deactivated

Hi, in sugar 6, I could prevent a record being deleted by doing this in custom/modules/Accounts/controller.php:

<?php

if (!defined('sugarEntry'))
    define('sugarEntry', true);

require_once 'include/MVC/Controller/SugarController.php';

class AccountsController extends SugarController {

    function action_delete() {
        if (empty($this->bean->some_field_c)) {
            parent::action_delete();
        }

        return;
    }
}

 

So the account would be deleted as long as some_field_c was empty. How can I do the same thing in sugar 7? It looks like custom/modules/Accounts/controller.php is no longer read. I know I can edit the record.js for accounts and catch the delete trigger and stop it there, but this is client side, plus I would need to do it for the recordlist view, massupdate view, etc. It would also mean that other apps accessing the sugar API delete these records.

 

I also tried the before_delete logic hook which does get called but you can't intercept the delete here.

 

Thanks.

Outcomes