AnsweredAssumed Answered

Adding a team to a record through coding using after_save logic hook not working

Question asked by Raymond Tham on Jan 24, 2018
Latest reply on Jan 28, 2018 by Karel Čech

Hi everyone,


I would like to add a team to a record through coding. I am using after_save logic hook but it is not add the team to the record. If I use before_save hook, then it’s working. I would like to use after_save hook as it is recommended by Sugar Documentation. I would appreciate if you can help. My Sugar version is Pro 7.9.20. Bellow is my coding:




    $hook_array['after_save'][] = Array(
        //Processing index. For sorting the array.

        //Label. A string value to identify the hook.
        'Add Team value before_save',

        //The PHP file where your class is located.

        //The class the method is in.

        //The method to call.



    if (!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');

    class AddTeam_class
        function add_team_method($bean, $event, $arguments)
            //loop prevention check
            if (!isset($bean->ignore_update_c) || $bean->ignore_update_c === false)
                $bean->ignore_update_c = true;
                $module = $bean->module_dir;
                $record_id = $bean->id;

                $GLOBALS['log']->fatal(">>>> add teams executed >>>>>");

                //Retrieve the bean
                $bean = BeanFactory::getBean($module, $record_id);

                //Load the team relationship

                $tl_team_id  = "a799aafc-d021-11e7-990a-00ff10f03434";
                $tcc_team_id = "b79db27c-d021-11e7-819e-00ff10f03434";
                $ft_team_id  = "d1f6ad5e-d021-11e7-a70e-00ff10f03434";

                //Add the teams

Sayfur Rahman, Francesca Shiekh, Ramana Raju SanthanaLori Arce