Just create a file /custom/modules/Contacts/ContactsVerify.php with the following code:
PHP Code:
<?php
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
class ContactsVerify {
function CheckValues(& $focus, $event, $arguments){
global $app_list_strings;
$GLOBALS['log']->debug("KUSKE HOOK CONTACT ".$event);
$GLOBALS['log']->debug("REQUEST:".print_r($_REQUEST,true));
$GLOBALS['log']->debug("FOCUS:".print_r($focus,true));
// ---------------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------------
if($event=="before_save"){
// ---------------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------------
if ( ($_REQUEST["module"] == "Leads" )
&& ($_REQUEST["action"] == "ConvertLead" )
&& ($_REQUEST["handle"] == "Save" ) )
{
$lead_id = $_REQUEST["record"];
require_once('modules/Leads/Lead.php');
$lead = new Lead();
$lead->retrieve($lead_id);
$GLOBALS['log']->debug("LEAD:".print_r($lead,true));
$focus->team_id = $lead->team_id;
}
// ---------------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------------
} // end if logic hook is beforesave
// ---------------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------------
} //end function CheckValues
} //end class ContactsVerify
?>
Then open /custom/modules/Contacts/logic_hooks.php and add the following line at the end:
PHP Code:
$hook_array['before_save'][] = Array(1, 'ContactsVerify', 'custom/modules/Contacts/ContactsVerify.php','ContactsVerify', 'CheckValues');
OR; if it does not exist write an own /custom/modules/Contacts/logic_hooks.php with following lines of code:
PHP Code:
<?php
$hook_version = 1;
$hook_array = Array();
// position, file, function
$hook_array['before_save'] = Array();
$hook_array['before_save'][] = Array(1, 'ContactsVerify', 'custom/modules/Contacts/ContactsVerify.php','ContactsVerify', 'CheckValues');
?>
That's all...
Bookmarks