AnsweredAssumed Answered

extending a view causes logic hook run twice

Question asked by Raymond Tham on Jan 22, 2018

i create a custom view called custom-stuff (custom-stuff.js and custom-stuff.hbs) and a before_save logic hook called setTeams.php. When i run the code, the before_save logic hook runs twice. After several attempts i realized that if remove "hasViewBasedMetadata: false," from the custom-stuff.js, the logic hook will run only once as desired. But I want to extend my custom view as it is recommended in the sugarcrm documentation. I dont really know what is the problem, but appreciate if anyone can help.



1. custom\modules\Cases\clients\base\views\custom-stuff.js

       extendsFrom: 'CasesRecordView',

       initialize: function(options) {
        this._super('initialize', [options]);


2. custom\modules\Cases\clients\base\views\custom-stuff.hbs

  <h2>hello world</h2>


3. sugarcrm\custom\Extension\modules\Cases\Ext\LogicHooks\setTeams.ext.php

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

        //Label. A string value to identify the hook.
        'Set teams before save',

        //The PHP file where your class is located.

        //The class the method is in.

        //The method to call.


4. sugarcrm\custom\modules\Cases\setTeams.php


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

    class SetTeams
        function set_teams($bean, $event, $arguments)
            if (!isset($bean->ignore2_update_c) || $bean->ignore_update_c === false)
                $bean->ignore2_update_c = true;
                $GLOBALS['log']->fatal(">>>> set teams >>>>>");               

                /*$GLOBALS['log']->fatal(">>>> End of setTeams >>>>>");*/


Ramana Raju Santhana, Francesca Shiekh, @Mehul  Bhandari