Sugarcrm,在保存记录的同时编写自定义代码 [英] Sugarcrm, writing custom code while saving the record

查看:19
本文介绍了Sugarcrm,在保存记录的同时编写自定义代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在定制 SugarCRM.在某些时候,我需要在用户创建记录时将一些自定义值存储到数据库中.我尝试使用触发器,但它没有满足要求.所以我需要用 PHP 代码编写.

I am customizing the SugarCRM. At some point I need to store some custom values to the database while user creates the record. I tried to use Triggers, but it didn't fulfill the requirement. So I need to write that in PHP code.

我的问题是,在哪里编写这段代码.

My question is, where to write this code.

推荐答案

在模块的保存操作上使用逻辑钩子(例如 after_save 或 before_save).

Use logic hooks (after_save or before_save e.g.) on the module's save action.

  • 在 custom/modules/myModule/

<?
$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/

  • Create file.php in /custom/modules/myModule/logic_hooks/

    <?php
    class myClass{
        function myMethod(&$bean, $event, $arguments){
            // Do something with $bean (e.g. store the custom DB value)
        }
    }
    ?>
    

  • 有关更多信息,请参阅:此链接.

    For more info see: this link.

    这篇关于Sugarcrm,在保存记录的同时编写自定义代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆