Reputation:
I want to implement a Sugar Logic Hook that fires when invoice status becomes validated.
This my logic hook:
<?php
$hook_version = 1;
$hook_array = Array();
$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');
?>`
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']->fatal("Status has been changed");
}
}
}
?>
What am I missing?
Upvotes: 0
Views: 211
Reputation: 14554
You need a double ==
or triple ===
(strict) to make a comparison. Using one =
is an assignment operator.
if ($dictionary['AOS_Invoices']['fields']['status'] == 'validated') {
Upvotes: 2
Reputation: 47
you must change the path in your logic hooks : 'custom/modules/AOS_Invoices/AOS_LogicHooks.php'
And change your code of your action class to:
<?php
class statusChange {
public function statusInvoicesChanges ($bean, $event, $arguments) {
// addition line:
$GLOBALS['log']-> debug(get_class()." ". __FUNCTION__." Status:\n ".print_r($bean->status,true));
if ($bean->status == 'Validated'){
$GLOBALS['log']-> debug("Status has been changed");
}
}
}
?>
Upvotes: 0