我想实现一个糖逻辑钩子,当发票状态变为有效时触发。
这是我的逻辑钩子:
<?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');
?>`这是我的action类:
<?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");
}
}
}
?>我遗漏了什么?
发布于 2020-09-08 23:28:48
您需要使用double ==或triple === (strict)进行比较。使用一个=是一个赋值运算符。
if ($dictionary['AOS_Invoices']['fields']['status'] == 'validated') { 发布于 2020-09-10 00:18:10
您必须更改逻辑钩子中的路径:'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");
}
}
}
?>https://stackoverflow.com/questions/63796991
复制相似问题