Table of Contents Previous Next

Sugar Developer Guide

Version 5.1


Chapter 4 Customizing Sugar : Business Logic Hooks : Using Custom Logic Hooks

Using Custom Logic Hooks
Above we showed how to create a custom_logic_hook that runs the function updateDescription() from the class updateDescription (those don't have to be the same, they just are in this example) in the PHP file updateDescription.php. Below is the actual script from that PHP file.
class updateDescription {
function updateDescription(&$bean, $event, $arguments) {
$bean->description = html_entity_decode($bean->description);
$bean->fetched_row['description'] = $bean->description;
}
}
You see that the $bean is fed into the function and allows access to all of the fields for the currently selected record. Any changes you make to the array will be reflected in the actual data. For example in this script we are changing the description field. As you see above there is
$event is set to whatever event is currently running like after_retrieve or before_delete.

Table of Contents Previous Next

Copyright 2004-2008 SugarCRM Inc.
Product License