开发者

Sugar CRM, Getting auto increment value in the custom field

开发者 https://www.devze.com 2023-03-09 13:06 出处:网络
I am using Sugar Professional 6 and also checking the same in community version. In project module, I have project Name which should generate automatically from another field called MSO with the prefi

I am using Sugar Professional 6 and also checking the same in community version. In project module, I have project Name which should generate automatically from another field called MSO with the prefix and auto increment number.

For ex.

MSO Code- Xyz Project Name 开发者_如何学编程should be- Xyz1

For next record

MSO Code- Abcd Project Name should be- Abcd1

MSO Code- Xyz Project Name should be- Xyz2


I would definately make it using logic hooks on the project module 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. load the MSO code and calculate the project name, and afterwards set the project name to the found value.)
        }
    }
    ?>
    

For more info see: http://developers.sugarcrm.com/docs/OS/6.1/-docs-Developer_Guides-Sugar_Developer_Guide_6.1.0-Chapter%204%20Customizing%20Sugar.html#9000530


if you want to generate the auto increment field just add simple field name unique id in the studio and go the database and change the value to the auto increment.

Thanks

0

精彩评论

暂无评论...
验证码 换一张
取 消