Sugarcrm, writing custom code while saving the record

浪尽此生 提交于 2019-12-08 08:14:42

问题


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.


回答1:


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

  • Create a logic_hooks.php in 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'
    );
    ?>
    
  • 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.




回答2:


Make sure that your_php_file.php is executable by apache. It could be that or possibly a misspelling? See if there is anything in your apache log files.



来源:https://stackoverflow.com/questions/7975679/sugarcrm-writing-custom-code-while-saving-the-record

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!