我正在使用 Sugar Professional 6 并在社区版本中检查相同的内容。在项目模块中,我有项目名称,它应该从另一个名为 MSO 的字段自动生成,带有前缀和自动增量编号。
例如。
MSO 代码- Xyz 项目名称应为 - Xyz1
为下一个记录
MSO 代码- Abcd 项目名称应为 - Abcd1
MSO 代码- Xyz 项目名称应为 - Xyz2
我肯定会在项目模块保存操作上使用逻辑钩子来实现它。
在 custom/modules/ myModule /中创建一个 logic_hooks.php
<?
$hook_array = Array();
$hook_array['after_save'] = Array();
$hook_array['after_save'][] = Array(0, 'myName', 'custom/modules/myModule/logic_hooks/file.php','myClass', 'myMethod');
?>
在 /custom/modules/ myModule /logic_hooks/中创建 file.php
<?php
class myClass{
function myMethod(&$bean, $event, $arguments){
// Do something with $bean (e.g. load the MSO code and calculate the project name, and afterwards set the project name to the found value.)
}
}
?>
有关更多信息,请参阅:http: //developers.sugarcrm.com/docs/OS/6.1/-docs-Developer_Guides-Sugar_Developer_Guide_6.1.0-Chapter%204%20Customizing%20Sugar.html#9000530
如果您想生成自动增量字段,只需在工作室中添加简单的字段名称唯一 ID,然后进入数据库并将值更改为自动增量。
谢谢