Hello, I want to show an error message when Invoice status becomes ‘validated’,
Here is my logic hook:
<?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, 'status invoices Changes', '/var/www/html/suitecrm/modules/AOS_Invoices/AOS_LogicHooks.php','AOS_LogicHooks', 'statusInvoicesChanges');
?>
And this is my action class :
<?php
class AOS_LogicHooks
{
public function statusInvoicesChanges (SugarBean $bean, $event, $arguments)
{
if ($dictionary['AOS_Invoices']['fields']['status'] == 'validated')
{
$GLOBALS['log']->debug("Status has been changed");
}
}
}
?>
So, when I open Admin>system settings>save the log. There is no display of my message. What i’m messing ?
Hi, @turik!
Here is your code. It’s more readable.
Look at line under my comment - ‘Error here’. You should delete ‘SugarBean’
<?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,
'status invoices Changes'
'/var/www/html/suitecrm/modules/AOS_Invoices/AOS_LogicHooks.php','AOS_LogicHooks',
'statusInvoicesChanges');
?>
<?php
class AOS_LogicHooks {
/* Error here */
public function statusInvoicesChanges (SugarBean $bean, $event, $arguments) {
if ($dictionary['AOS_Invoices']['fields']['status'] == 'validated'){
$GLOBALS['log']->debug("Status has been changed");
}
}
} ?>
Hi @p.konetskiy ! thank you for your reply
I deleted SugarBean and there is no display of my debug log.
This what I mean by status of invoices becomes ‘validated’
@diligent I try it
if ($bean->status == ‘validated’){
$GLOBALS[‘log’]->debug(“Status has been changed”);
}
And nothing happen.
I m gonna try to show you with pictures the steps:
<?php
class AOS_LogicHooks {
public function statusInvoicesChanges ($bean, $event, $arguments) {
if ($bean->status == 'Validated'){
$GLOBALS['log']->debug("Status has been changed");
}
}
}
?>
Check capital letter for value ‘Validated’ or ‘validated’
@p.konetskiy I try it and nothing happen. I think maybe the location of my logic hook and action class file is worng. i put it under the modules AOS_Invoices : /var/www/html/suitecrm/modules/AOS_Invoices
Sorry to get into the conversation. I think you have to learn and understand the basic logic-hook structure and implementation before you embark in doing your own hooks. As @diligent and @p.konetskiy point out before, you should start by reading the documentation: https://docs.suitecrm.com/developer/logic-hooks/
@BrozTechnologies Thank for your help,
the problem was solved, i had to change the name of my hook file to “logic_hooks” and it works. special thank to @p.konetskiy and @diligent