逻辑钩子仅在 $bean->status 改变时触发

logic hook fires only when $bean->status changes

我想实现一个当发票状态更改为 'Validated' 时触发的 Sugar 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'); 
?>

这是我的操作 class:
<?php class AOS_LogicHooks {
 public function statusInvoicesChanges (SugarBean $bean, $event, $arguments){
if($bean->status == 'Validated' && $bean->fetched_row->status <> $bean->status){ 
$GLOBALS['log']->fatal("Status has been changed");
}}}
?>  


我错过了什么?

我们都会犯的一个简单错误,获取的行是一个数组,因此您无法以 属性.

的形式访问内容

我刚刚测试了这个并且工作正常!看看:

<?php 

class AOS_LogicHooks
{
  public function statusInvoicesChanges(SugarBean $bean, $event, $arguments)
  {
    if ($bean->status == 'Validated' && !empty($bean->fetched_row) && $bean->fetched_row['status'] <> $bean->status) {
      $GLOBALS['log']->fatal("Status has been changed");
    }
  }
}