Sugarcrm, writing custom code while saving the rec

2019-06-02 08:22发布

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.

2条回答
我命由我不由天
2楼-- · 2019-06-02 08:38

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.

查看更多
3楼-- · 2019-06-02 08:56

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.

查看更多
登录 后发表回答