如何在sugar crm中添加两个数字
我进行了模块加法,并在此创建了三个字段 amount1_c
、amount2_c
和 total_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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
代码看起来是正确的。
自定义逻辑挂钩不起作用时的一些常见“错误”:
LogicHookMath.php
)$bean
变量以&
为前缀,因此该变量作为引用传递logic_hooks.php
和LogicHookMath.php
文件可读由网络服务器用户如果上述方法没有帮助,请尝试使用
$GLOBALS['log']->info( "Value 3: " 将进度记录到 Sugarcrm.log . $field3);
在自定义逻辑挂钩中。The code looks correct.
Some common "mistakes" when custom logic hooks are not working:
LogicHookMath.php
)$bean
variable is prefixed with&
, so the variable is passed as a referencelogic_hooks.php
and theLogicHookMath.php
files are readable by the web server userIf 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.