Hello all! I recently stood up a SuiteCRM 8.9.1 server and have received lots of customization requests. Many of which have been achievable through the workflow manager, but this seems like it might need a logic hook and even after reading the section on logic hooks in the dev docs, I can’t seem to get the hook to ever fire. Any help very much appreciated!
/var/www/suitecrm/public/legacy/custom/modules/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, 'ElasticSearch Index Changes', 'lib/Search/ElasticSearch/ElasticSearchHooks.php','SuiteCRM\\Search\\ElasticSearch\\ElasticSearchHooks', 'beanSaved');
$hook_array\['after_save'\]\[\] = Array(1, 'addCompanyToTask', '/var/www/suitecrm/public/legacy/custom/modules/Tasks/copyCompany.php', 'CopyCompany', 'copyFromLead');
$hook_array\['after_save'\]\[\] = Array(30, 'popup_select', 'modules/SecurityGroups/AssignGroups.php','AssignGroups', 'popup_select');
$hook_array\['after_delete'\] = Array();
$hook_array\['after_delete'\]\[\] = Array(1, 'ElasticSearch Index Changes', 'lib/Search/ElasticSearch/ElasticSearchHooks.php','SuiteCRM\\Search\\ElasticSearch\\ElasticSearchHooks', 'beanDeleted');
$hook_array\['after_ui_footer'\] = Array();
$hook_array\['after_ui_footer'\]\[\] = Array(10, 'popup_onload', 'modules/SecurityGroups/AssignGroups.php','AssignGroups', 'popup_onload');
$hook_array\['after_ui_frame'\] = Array();
$hook_array\['after_ui_frame'\]\[\] = Array(20, 'mass_assign', 'modules/SecurityGroups/AssignGroups.php','AssignGroups', 'mass_assign');
$hook_array\['after_ui_frame'\]\[\] = Array(1, 'Load Social JS', 'include/social/hooks.php','hooks', 'load_js');
?>
/var/www/suitecrm/public/legacy/custom/modules/Tasks/logic_hooks.php
<?php
// Do not store anything in this file that is not part of the array or the hook version.
$hook_version = 1;
$hook_array = Array();
$hook_array\['after_save'\] = Array();
$hook_array\['after_save'\]\[\] = Array(1, 'Copy company from related Lead', 'custom/modules/Tasks/TaskCompanyHook.php', 'TaskCompanyHook', 'copyCompany');
?>
/var/www/suitecrm/public/legacy/custom/modules/Tasks/TaskCompanyHook.php
class TaskCompanyHook
{
public function copyCompany($bean, $event, $arguments)
{
file_put_contents('/tmp/task_hook.log', date('Y-m-d H:i:s') . " HOOK FIRED\\n", FILE_APPEND);
file_put_contents('/tmp/task_hook.log', "parent_type: " . $bean->parent_type . "\\n", FILE_APPEND);
file_put_contents('/tmp/task_hook.log', "parent_id: " . $bean->parent_id . "\\n\\n", FILE_APPEND );
if (in_array($bean->parent_type, array('Leads', 'Lead')) && !empty($bean->parent_id))
{
$lead = BeanFactory::getBean('Leads', $bean->parent_id);
if (!empty($lead->id))
{
$bean->company_c = $lead->account_name;
}
}
}
}
This gets auto generated after rebuild and repair
/var/www/suitecrm/public/legacy/custom/modules/Tasks/Ext/LogicHooks/logichooks.ext.php
<?php
//WARNING: The contents of this file are auto-generated
$hook_array\['after_save'\]\[\] = array( 1, 'Copy company from related Lead', 'custom/modules/Tasks/TaskCompanyHook.php', 'TaskCompanyHook', 'copyCompany' );
?>