AnsweredAssumed Answered

Sugar 7 - Remove subpanel in CreateView and EditView with javascript

Question asked by Ramon Marcondes on Nov 22, 2016
Latest reply on Nov 23, 2016 by Jeff Bickart


I'm using SugarCRM 7.7.

There is a module called Opportunities, that is related to a module called RevenueLineItems.

The RevenueLineItems subpanel is the only one that appears on creating or editing a Opportunity. I need to remove it completely, including any validation to its fields.

The "Show modules and subpanels" system option sort of does it, but it removes the subpanel in all views, and I need to do it only in CreateView and EditView.

I found a way to remove the subpanel via layout, but it becomes hidden only in DetailView...

It was like this:  (custom\modules\Opportunities\clients\base\layouts\subpanels\subpanels.js):

    extendsFrom: 'SubpanelsLayout',
    hide_subpanel_by_type: ['revenuelineitems'],

    initialize: function (options) {
        app.view.invokeParent(this, {type: 'layout', name: 'subpanels', method: 'initialize', args: [options]});
     * Show the subpanel for the given linkName and hide all others
     * @param {String} linkName name of subpanel link

    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) {
                //console.log("Module: "+component.module.toLowerCase());
                var hide_subpanel = self._checkIfHideSubpanel(component.module.toLowerCase(), component.collection);

                var link = component.context.get('link');
                if (!hide_subpanel &&
                    ( !linkName || linkName === link )) {
                    component.context.set("hidden", false);
                else {
                    component.context.set("hidden", true);

     * Check if the subpanel is on the hiding list and if the watched field has a specific value.
     * @param {Boolean} subpanel name of the module for the subpanel

    _checkIfHideSubpanel: function (type, field_collection) {
        var relationship =;
        var self = this;
        var hide_subpanel = false;
        if (( jQuery.inArray(type, self.hide_subpanel_by_type) !== -1 )) {
            hide_subpanel = true;
        return hide_subpanel;


The big question is: how can I access the subpanel component in a CreateView and in a RecordView, and remove the subpanel using javascript?

Any help would be appreciated.




Ramon Marcondes