如何在sugar crm中添加两个数字

发布于 2024-11-18 15:20:51 字数 777 浏览 3 评论 0原文

我进行了模块加法,并在此创建了三个字段 amount1_camount2_ctotal_amount_c 将两个数字相加并在第三个字段中显示结果。我在逻辑中完成了编码,看起来这里是我的代码

<?
$hook_version = 1;     
$hook_array = Array();      
$hook_array['before_save'] = Array();     
$hook_array['before_save'][] = Array(1,'calculate_field', 'custom/modules/cases/LogicHookMath.php','LogicHookMath', 'calculate_field');    
?> 

,并制作了另一个文件逻辑钩子数学。这是我的代码

<?php
class LogicHookMath {
    function calculate_field(&$bean, $event, $arguments) {
        $field1 = $bean->amount1_c;
        $field2 = $bean->amount2_c;
        $field3 = $field1 + $field2;
        $bean->amount_total_c = $field3;
    }
}
?>

,但我仍然没有得到任何结果。请帮我解决这个问题。

I made module addition and in this made three fields amount1_c, amount2_c and total_amount_c to add the two numbers and display the result in the third field. I done coding in the logic looks here is my code

<?
$hook_version = 1;     
$hook_array = Array();      
$hook_array['before_save'] = Array();     
$hook_array['before_save'][] = Array(1,'calculate_field', 'custom/modules/cases/LogicHookMath.php','LogicHookMath', 'calculate_field');    
?> 

and made one more file logic hook math. here is my code for

<?php
class LogicHookMath {
    function calculate_field(&$bean, $event, $arguments) {
        $field1 = $bean->amount1_c;
        $field2 = $bean->amount2_c;
        $field3 = $field1 + $field2;
        $bean->amount_total_c = $field3;
    }
}
?>

but still i did not get any result. Please help me out for this.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

哥,最终变帅啦 2024-11-25 15:20:51

代码看起来是正确的。

自定义逻辑挂钩不起作用时的一些常见“错误”:

  • 确保自定义逻辑挂钩具有正确的名称 (LogicHookMath.php)
  • 确保 $bean变量以 & 为前缀,因此该变量作为引用传递
  • 确保 logic_hooks.phpLogicHookMath.php 文件可读由网络服务器用户
  • 整个自定义目录也应该可供 Web 服务器用户写入

如果上述方法没有帮助,请尝试使用 $GLOBALS['log']->info( "Value 3: " 将进度记录到 Sugarcrm.log . $field3); 在自定义逻辑挂钩中。

The code looks correct.

Some common "mistakes" when custom logic hooks are not working:

  • Make sure, the custom logic hook has the correct name (LogicHookMath.php)
  • Make sure, that the $bean variable is prefixed with &, so the variable is passed as a reference
  • Make sure the logic_hooks.php and the LogicHookMath.php files are readable by the web server user
  • The entire custom directory should also be writeable for the web server user

If the above does not help, try logging the progress to the sugarcrm.log using $GLOBALS['log']->info( "Value 3: ". $field3); in the custom logic hook.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文