I am following the Logic Hook documentation but got tripped up along the way since it is not working.
This logic hook is intended to redirect to the Calendar module instead of the default Detailview after save of a custom module.
\custom\modules\time_MonthlyTimesheet\Logic_Hooks.php
<?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['after_save'] = Array();
$hook_array['after_save'][] = Array(1, 'Post save redirect', 'custom/modules/time_MonthlyTimesheet/postsaveRedirect.php','postsaveRedirect', 'redirect');
?>
\custom\modules\time_MonthlyTimesheet\postsaveRedirect.php
<?php
class postsaveRedirect
{
public function redirect(SugarBean $bean, $event, $arguments)
{
if ($bean->module_name == 'time_MonthlyTimesheet') {
return;
}
if (defined('sugarEntry') && defined('SUGARCRM_IS_INSTALLING')) {
return;
}
try {
$params = array(
'module'=> 'Calendar',
'action'=>'index',
'parentTab' => 'all'
);
SugarApplication::redirect('index.php?' . http_build_query($params));
// header('Location: http://127.0.0.1/SuiteCRM/index.php?module=Calendar&action=index&parentTab=All');
// exit;
} catch (Exception $ex) {
$GLOBALS['log']->error($ex->getMessage());
}
}
}
If anyone could correct my code or the placement of these files in the directory, it would be greatly appreciated.