Hide Panels in record View in 7.6 using Dependancies?

Following various posts here I am trying to conditionally Show/Hide some panels on a record view using dependencies.

I have tried the following but clearly have a problem as it is not working.

IF someone can point out the error of my ways I would really appreciate it.

The panels are in a custom module with the system name of "sior_Referrals"

Their visibility should be set by a drop down field called "ref_type" in that module with the values "In" or "Out".

If it is "In"

LBL_RECORDVIEW_PANEL1 should be Visible

LBL_RECORDVIEW_PANEL2 should be Hidden

If it is "Out"

LBL_RECORDVIEW_PANEL2 should be Visible

LBL_RECORDVIEW_PANEL1 should be Hidden

I am putting the following code in a file here:

\custom\modules\sior_Referrals\Ext\Dependencies\deps.ext.php

<?php

$dependencies['sior_Referrals']['ref_type'] = array(

  'hooks' => array("edit","view"),

  'trigger' => 'true',

  'triggerFields' => array('ref_type'), 

  'formula' => 'equal($ref_type, "In")',

  'onload' => true,

  'actions' => array(  

  array( 'name' => 'SetPanelVisibility',

            'params' => array(  'target' => 'LBL_RECORDVIEW_PANEL1',    

                                          'value' => true,   

                                          ),  

                ), 

  array( 'name' => 'SetPanelVisibility',

            'params' => array( 'target' => 'LBL_RECORDVIEW_PANEL2',    

                                          'value' => false,   

                                              ),  

            ), 

                               ),

  );

$dependencies['sior_Referrals']['ref_type'] = array(

  'hooks' => array("edit","view"),

  'trigger' => 'true',

  'triggerFields' => array('ref_type'), 

  'formula' => 'equal($ref_type, "Out")',

  'onload' => true,

  'actions' => array(  

  array( 'name' => 'SetPanelVisibility',

            'params' => array(  'target' => 'LBL_RECORDVIEW_PANEL2',    

                                          'value' => true,   

                                          ),  

                ), 

  array( 'name' => 'SetPanelVisibility',

            'params' => array( 'target' => 'LBL_RECORDVIEW_PANEL1',    

                                          'value' => false,   

                                              ),  

            ), 

                               ),

  );

  • Hi Greg,

    PanelVisibility dependency will work based on condition meets,

    When condition meets,then panel will be visible.

    When conditions are not matching panel will be hidden.

    condition can be like below,

    'value' => 'equal($sales_stage, "Prospecting")',
    
    'value' => 'not(equal($sales_stage, "Prospecting"))',
    

    So create a file below path.

    custom/Extension/modules/Opportunities/Ext/Dependencies/hidetabs.php

    and add your code like below.

    <?php
    $dependencies['Opportunities']['hide_tabs']=array(
     'hooks' => array("edit","view"),
        'trigger' => 'true',
        'triggerFields' => array('sales_stage'),  // what field should this be triggered on
        'onload' => true,
        'actions' => array(
            array(
                'name' => 'SetPanelVisibility',  // the action you want to run
                'params' => array(
                    'target' => 'LBL_RECORDVIEW_PANEL1',  // name of the panel, can be found in the vardefs.
                    'value' => 'equal($sales_stage, "Prospecting")',  // the formula to run to determine if the panel should be hidden or not.
                ),            
            ),        
        ),
        );
    ?>
    

    Here i am checking sales_stage field.When sales stage becomes to "Prospecting",then panel(LBL_RECORDVIEW_PANEL1) will be shown.Otherwise it will be hidden.

    Try the same for your case, and play around like "not(equal($sales_stage, "Prospecting"))"

    Hope this helps!.

  • Thanks Ajay.

    I will give it a try.

    How would I need to change it so it worked with TABs instead of Panels within the record view?

    Greg

  • Hi Greg,

    It will work for both(tab and panel).

    I gave a try in my local instance for both panel and tab.

    It is working fine.

    Note : Dependencies will work for both createview and record view as well.

  • Thanks Ajay Kumar

    I have it working, but not quite doing what i would like....

    <?php

    $dependencies['sior_Referrals']['ref_type'] = array(

      'hooks' => array("edit","view"),

      'trigger' => 'true',

      'triggerFields' => array('ref_type'),

      'onload' => true,

      'actions' => array( 

            array( 'name' => 'SetPanelVisibility',

                       'params' => array(  'target' => 'LBL_RECORDVIEW_PANEL1',   

                                                        'value'  => 'equal($ref_type,"In")',  

                                                   ),

                     ),

           ),

      );

    How do I amend this so I am controling the visibility of other panels?

    LBL_RECORDVIEW_PANEL2 or LBL_RECORDVIEW_PANEL3 etc

    Is it anotehr Dependancy file? - tried that didn't work for me.

    Is it some sort of if\elseIf statement?

    What would work best?

    Thanks

    Greg

  • Hi Greg,

    If i understood correctly,

    In the same dependency file we can write one more or many dependency.

    <?php
    $dependencies['sior_Referrals']['unique_name'] = array(
    //logic  1 here
      );
    
    $dependencies['sior_Referrals']['unique_name_1'] = array(
    //logic  2 here
      );
    

    With the conditions similar like

    we use conditions like below,

    'value' => 'equal($sales_stage, "Prospecting")', 
    
    'value' => 'not(equal($sales_stage, "Prospecting"))', 
    
  • Thanks Ajay

    Following your guidance This is what worked for me ...

     <?php
    $dependencies['sior_Referrals']['ref_type_out'] = array(
      'hooks' => array("edit","view"),
      'trigger' => 'true',
      'triggerFields' => array('ref_type'), 
      'onload' => true,
      'actions' => array(  
       array( 'name' => 'SetPanelVisibility',
      'params' => array(  'target' => 'LBL_RECORDVIEW_PANEL2',    
      'value'  => 'equal($ref_type,"Out")',   
       ),  
      ), 
                        ),
      );
    $dependencies['sior_Referrals']['ref_type_in'] = array(
      'hooks' => array("edit","view"),
      'trigger' => 'true',
      'triggerFields' => array('ref_type'), 
      'onload' => true,
      'actions' => array(  
       array( 'name' => 'SetPanelVisibility',
      'params' => array(  'target' => 'LBL_RECORDVIEW_PANEL1',    
      'value'  => 'equal($ref_type,"In")',   
       ),  
      ), 
                        ),
      );