Remove subpanel from a module

Hi All

How can we remove subpanel from a Module? I want to remove contacts subpanel from Accounts Module (In two ways :-One is simply hide and other is based on some condition,I want to hide contacts Subpanel from Accounts Module.I tried to hide subpanel using below modiification:

unset($layout_defs['Accounts']['subpanel_setup']['Contacts']);

But it did not work in sugarcrm 7.6 version.Please let me know how can we do this.

  • Hello Harpeet,

    One possible way to fix this is to copy

    modules/MODULE/clients/base/layouts/subpanels/subpanels.php

     

    to

     

    custom/modules/MODULE/clients/base/layouts/subpanels/subpanels.php

     

    and removes or comment out the arrays from the custom file. For example, if you wanted to get rid of the Leads subpanel, you would comment out or remove

     

        array (

          'layout' => "subpanel",

          'label' => 'LBL_LEADS_SUBPANEL_TITLE',

          'context' => array (

            'link' => 'leads',

          ),

     

    Be sure to go to Admin > Repair > Quick Repair and Rebuild to have these changes stick.

     

    Kind Regards,

     

    Jason Smith

  • Hi

    Thanks for your reply.It worked..:)

    Could you please also help me to know what can we do in those cases where we need to hide a module based on conditions.Like for example in Accounts Module,If for some record there is no description available then we need to hide contacts module.

    How can we do this

  • Hi Justin

    I checked that and based on the solution provided I also did changes in my code and used below logic.but I am facing issue.Actually the code which iterates through each component and hide or show Submodule is not working.Can anyone please check and let me know where I am wrong/ below is the code:

    ({

    extendsFrom: 'SubpanelsLayout',

        check_field: 'description',

        hide_on_value: '',

        hide_subpanels: 'contacts',

       

         initialize: function (options)

        {

            app.view.invokeParent(this, {type: 'layout', name: 'subpanels', method: 'initialize', args:[options]});

        },

       

        showSubpanel: function(linkName) {

             var hide_subpanel = false;

            var self = this,

                //this.layout is the filter layout which subpanels is child of; we

                //use it here as it has a last_state key in its meta

                cacheKey = app.user.lastState.key('subpanels-last', this.layout);

          if (linkName) {

                app.user.lastState.set(cacheKey, linkName);

            }

            this.model.on("change", function() {

            var val = this.get(this.check_field);

              if(val == null || val == '') {

                     hide_subpanel = true;

               }

           

           _.each(this._components, function(component) {

      

                var link = component.context.get('link');

                if (!hide_subpanel && (!linkName || linkName === link)) {

      component.context.set("hidden", false);

      console.log("show");

                    component.show();

                } else {

      component.context.set("hidden", true);

      console.log("hide");

                    component.hide();

                }

            });

           

           

             });

          },

         

         

    })

  • Hi Harpreet Kaur,

    Can you please try below code in /custom/modules/Accounts/clients/base/layouts/subpanels/subpanels.js,

    ({

        extendsFrom: 'SubpanelsLayout',

       initialize: function (options) {

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

        },

         showSubpanel: function (linkName) {

            var self = this,

            //this.layout is the filter layout which subpanels is child of; we

            //use it here as it has a last_state key in its meta

            cacheKey = app.user.lastState.key('subpanels-last', this.layout);

            // wait for the model to load

            self.model.on("change", function () {

                if (linkName) {

                    app.user.lastState.set(cacheKey, linkName);

                }

                _.each(self._components, function (component) {

                    var link = component.context.get('link');

                      if(link=='contacts'){                

                         component.context.set("hidden", true);

                         component.hide();                  

                    }

                    else {

                        component.context.set("hidden", false);

                        component.show();                  

                    }               

                });

            });

        },

    })

    Thanks!.

  • Hi Ajay

    Thanks for your response.I already did that and It is working fine now.Issue was coming due to use of this operator at place of self and this concept was little bit uncleared before.Could you please let me know any good tutorials or any other practices for improvement of practices in SugarCRM.

    Thanks in advance.

  • Hi Harpreet Kaur,

    It is good to hear that is working fine.You can refer developer guide as shijin suggested and also you can attend training which is giving by sugar university.Sugar engineers are only handling online training for free cost every month,you can also attend.

    Here is the link for upcoming developer essentials training

    Sugar Developer Essentials - SugarCRM

    For administration training

    Sugar Administration Essentials - SugarCRM

    and Their developer blog

    Sugar Developer Blog – SugarCRM

    Thanks!.

  • Jason Smith

    Thanks so much for providing this answer back on November. Great help for me  One thing though. I tried it and found out that you seem to have accidentally left out one parenthesis, at least I got 500 error when commenting out just what you outline.

    However, commenting out or deleting this piece of code works:

    array (

          'layout' => "subpanel",

          'label' => 'LBL_LEADS_SUBPANEL_TITLE',

          'context' => array (

            'link' => 'leads',

          ),

    ),

    Thanks again,

    KGM

    Ent 

    7.7.1.0

  • Hello Kristjan,

    Thanks for pointing out the error, must've overlooked it on the copy. Glad it all worked out!

    Kind Regards, 

    Jason Smith