Last active
November 13, 2015 23:28
-
-
Save mmarum-sugarcrm/2bcb650771c45e89c03c to your computer and use it in GitHub Desktop.
Example Sugar 7 before_save Logic Hook
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
* Copyright 2015 SugarCRM Inc. | |
*/ | |
/** | |
* Example of a module logic hook that we will unit test | |
*/ | |
if (!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); | |
class AccountsOnSaveHooks | |
{ | |
function setIndustryForAnalystAccount($bean, $event, $arguments) | |
{ | |
//generic condition | |
if ($bean->account_type == 'Analyst') | |
{ | |
//update | |
$bean->industry = 'Banking'; | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
* Copyright 2015 SugarCRM Inc. | |
*/ | |
$hook_array['before_save'][] = Array( | |
//Processing index. For sorting the array. | |
1, | |
//Label. A string value to identify the hook. | |
'before_save example', | |
//The PHP file where your class is located. | |
'custom/modules/Accounts/AccountsOnSaveHooks.php', | |
//The class the method is in. | |
'AccountsOnSaveHooks', | |
//The method to call. | |
'setIndustryForAnalystAccount' | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment