AnsweredAssumed Answered

how to hide/show (js maybe) some elements in SugarCrm? universal resolve very very need! Thx

Question asked by Alex Kolchuginsky on Mar 22, 2016
Latest reply on Jul 13, 2017 by André Lopes

when we choose opportunity_type for example "Покупка", so lbl_stage_purchase field must show and the other fields below must hide (sales stage, lbl_stage_newbuilding, lbl_mortage_stage). If we choose another opportnity_type, then another lbl_... from the left (screen picture list) will stay show but other fileds must hide.

already tried this How to hide and show field from detail view of any module 

but nothing to success.

 

2016-03-23 00-26-34 Create » Opportunities » SuiteCRM.png

 

my code:

 

i created js file named universal.js with code which have to hide "lbl_stage_purchase":

 

function checkMobileForm(){

    var value = document.getElementById("opportunity_type").value;

    if(value == 'purchase'){

        document.getElementById("LBL_STAGE_PURCHASE").style.display = 'block';

    }

    else{

        document.getElementById("LBL_STAGE_PURCHASE").style.display = 'none';

    }

}

checkMobileForm();

//end

 

in file editviewdefs.php i include this js code:

 

'javascript' => '{$PROBABILITY_SCRIPT}',

      'includes' =>

            array (

                0 =>

                    array (

                        'file' => 'custom/include/javascript/universal.js',

                    ),

            ),

      'useTabs' => false,

 

same file, implemented this code to activate rule:

 

       3 =>

        array (

          0 =>

          array (

            'name' => 'stage_purchase_c',

            'studio' => 'visible',

            'label' => 'LBL_STAGE_PURCHASE',

       'displayParams' =>

                  array(

                      'field' =>

                          array(

                              'onChange' => 'checkMobileForm()',

                          ),

                  ),

      

          ),

          1 => '',

        ),

        4 =>

        array (

          0 => 'sales_stage',

          1 => 'lead_source',

        ),

        5 =>

        array (

          0 =>

          array (

            'name' => 'stage_newbuilding_c',

            'studio' => 'visible',

            'label' => 'LBL_STAGE_NEWBUILDING',

               'displayParams'

          ),

          1 => '',

        ),

 

what i do completely wrong? pls, help!

Outcomes