I am trying to execute a stored procedure from a logic hook in order to be able to set a field in CRM based on some criteria that may change from time to time. The best way we saw fit was to call the stored procedure from the logic hook, pass it the ID Guid and then modify the fields on the database backend via the stored procedure.
So far I have modified the /custom/modules/phones/logic_hook.php to look like this:
<?php
// Do not store anything in this file that is not part of the array or the hook version. This file will
// be automatically rebuilt in the future.
$hook_version = 1;
$hook_array = Array();
// position, file, function
$hook_array['before_save'] = Array();
$hook_array['before_save'][] = Array(1, 'workflow', 'include/workflow/WorkFlowHandler.php','WorkFlowHandler', 'WorkFlowHandler');
$hook_array['after_save'][] = Array(2, void, 'custom/modules/phone_Phones/phones_cstm.php', 'Phones_cstm', 'phone_after_save_1');
?>
and the custom logic hook file, /custom/modules/phones/phones_cstm.php:
<?php
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
class Phones_cstm
{
function phone_after_save_1()
{
//sleep(5);
global $currentModule;
//$query = "EXEC sp_phoneSaveHandler '$this->id';";
$query = "exec sp_phoneSaveHandler '35D9FD03-C09D-493A-9A3D-D3D8F3FF0485';";
$GLOBALS['log']->fatal($query);
$result = $bean->db->query($query, true);
//$db->query($query, true);
}
}
?>
I have tried all sorts of things and all I get upon save is this:
(the values from the page, then below
Fatal error: Call to a member function query() on a non-object in E:\SugarCRM\custom\modules\phone_Phones\phones_cst m.php on line 14
and in the log:
04/28/11 14:18:05 [916][4eeb5a12-9668-6122-189f-47bb36dd9632][FATAL] exec sp_phoneSaveHandler '35D9FD03-C09D-493A-9A3D-D3D8F3FF0485';
any quick solutions on how to do this correctly??


LinkBack URL
About LinkBacks




Reply With Quote


Bookmarks