Skip to content

Instantly share code, notes, and snippets.

@mmarum-sugarcrm
Last active November 13, 2015 23:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mmarum-sugarcrm/2bcb650771c45e89c03c to your computer and use it in GitHub Desktop.
Save mmarum-sugarcrm/2bcb650771c45e89c03c to your computer and use it in GitHub Desktop.
Example Sugar 7 before_save Logic Hook
<?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';
}
}
}
<?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