这是我第一次尝试编码sugarCRM/suiteCRM。尝试在创建或更新任务时向suiteCRM添加逻辑挂钩
我应该说我已经为Wordpress编写了将近10年的版本,但现在我已经完全失去了开始挖掘suiteCRM。
我读过,你可以添加一个逻辑钩将其保存到数据库后修改的数据,但我不知道从哪里开始...
想象我创建任务的今天, 7月7日,与我每2个月访问一次的客户有关,因此在账户中有一个名为“访问频率”的字段。我希望在任务的“未来访问日期”字段中添加未来日期(7月7日+60天= 9月7日aprox),以便我可以通过工作流程使用它创建特定的未来任务。
我想要做的是计算任务中的字段(未来访问日期),相当于添加到任务自己的日期字段的账户模块字段(访问频率)的天数。
我已经能够使它工作,使用以下布局:
内\custom\modules\Tasks\logic_hooks.php
<?php
$hook_version = 1;
$hook_array['before_save'] = Array();
$hook_array['before_save'][] = Array(
1, //Processing index. For sorting the array.
'future_task_date_on_task_creation', //Label. A string value to identify the hook.
'custom/modules/Tasks/future_visit_date.php', //The PHP file where your class is located.
'before_save_class', //The class the method is in.
'future_visit_date' //The method to call.
);
?>
里面\定制\模块\任务\ future_visit_date.php
<?php
if (!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
class before_save_class {
function future_visit_date($bean, $event, $arguments) {
$bean->rhun_fecha_sig_c = date("Y-m-d H:i:s", $date);
}
}
?>
通过此设置,未来访问日期将被填充计算日期。
我也读了是不建议此设置,而且我应该使用扩展框架,并把第一个文件的路径:
/custom/Extension/modules/Tasks/Ext/LogicHooks/<file>.php
但我不能使它发挥作用。
如果不在那里,我是否必须创建LogicHooks文件夹? 我应该为这个文件分配哪个文件名? 我是否必须更改代码内的其他内容?
谢谢,现在我做它的工作! –