我想实现一个糖逻辑钩子,该钩子会在发票状态验证后触发。
这是我的逻辑钩子
<?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');
?>`
这是我的动作课:
<?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");
}
}
}
?>
我想念什么?
答案 0 :(得分:2)
您需要使用两个==
或三个===
(严格)进行比较。使用一个=
是赋值运算符。
if ($dictionary['AOS_Invoices']['fields']['status'] == 'validated') {
答案 1 :(得分:0)
您必须更改逻辑挂钩中的路径:'custom/modules/AOS_Invoices/AOS_LogicHooks.php'
并将您的动作类代码更改为:
<?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");
}
}
}
?>