Introduction
SugarCRM Logic Hooks allows you to append actions to system events such as when creating, editing, and deleting records. This post gives you fast info how to implement them properly. For detail info read documentation linked at end of the post.
Implementation
Add php hooks_arrays in: /custom/extensions/modules/{module}/Ext/LogicHooks
$hook_array['before_save'][] = Array(
//Processing index. For sorting the array.
1,
//Label. A string value to identify the hook.
'before_save hook',
//The PHP file where your class is located.
'custom/modules/Quotes/hooks/QuotesHook.php',
//The class the method is in.
'QuotesHook',
//The method to call.
'beforeSave'
);
Add logic to file in: /custom/modules/{module}/hooks/
Basically it needs to match php file location and name like defined above in $hook_array. Also it needs to have class and function same as declared in $hook_array.
i.e. module hooks can be called on events like: before_safe, after_save, etc.
class OpportunitiesHook {
public function beforeSave(&$bean, $event, $arguments)
{
//$GLOBALS["log"]->fatal("beforeSave called!!");
if ($event != 'before_save') {
return;
}
}
}
Documentation
Full documentation about logic hooks you can find here.
Read about SugarCRM logging here.
Comments
SugarCRM - Log and logging - Compiled web learn how to use SugarCRM log
[…] Read about SugarCRM Logic Hooks here. […]
Extending SugarCRM Logic - Compiled web - SugarCRM custom expressions
[…] about SugarCRM Logic Hooks here or check our other […]