How to prevent saving in SuiteCRM


I need to develop a module which checks if an event is overlapping other one.

When some conditions are met, the events should be considered overlapped. When this happens the saving process should not be carried on and the user should be warned.

I’m doing this with the logic hook before_save.

In logic_hooks of the module

$hook_array['before_save'] = Array();
$hook_array['before_save'][] = Array(
    //Processing index. For sorting the array.

    //Label. A string value to identify the hook.
    'before_save example',

    //The PHP file where your class is located.

    //The class the method is in.

    //The method to call.

The file “logic_hooks_class.php” has these code:


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

    class logic_hooks_class
    //  extends SugarApi // Tried to use SugarAPI as seen googling, but these class does not exist in SuiteCRM
        function before_save_method($bean, $event, $arguments)
          throw new SugarApiException("Error Message to TEST!", null, 'Meetings', 550); // logically if SugarApi is not extenden we can't use these Exception


Anyone knows how to implement these behaviour or how to use SuiteCRM Exceptions?

Thanks in advance.