Module record pages not working with code following the new Sugar standards

Hello.

I'm using SugarCRM 7.8 Enterprise Edition.

I have a package for the module 'Opportunities', which I need to update some javascript / sidecar code to make the CRM updatable to version 7.9, according to what Sugar said in a Internal Case I opened (Healthcheck Failure).

The code change in question is this:

https://support.sugarcrm.com/Knowledge_Base/Installation_Upgrade/Troubleshooting_Health_Check_Output/Health_Check_Error_… 


There is a single line of code that makes a difference between the package working or not.

- This javascript line (deprecated method) works, but due to version update, I won't be able to use this anymore:

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

- But why these lines (adapted for Sugar 7.9) doesn't work?

Method A:

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

Method B:

this._super('initialize', {type: 'view', name: 'record', method: 'initialize', args: [options]});

I get these two errors:
- Cannot read property 'components' of undefined
- Cannot read property 'meta' of undefined

What could be the problem?

Any help would be appreciated.

Thanks.

Regards,

Ramon Marcondes

  • Hi Ramon Marcondes 

    Can you kindly provide content of your js controller on Opportunities?

    Cheers

    André Lopes
    Lampada Global
    Skype: andre.lampada
  • Hello, André.

    This is the code (custom/modules/Opportunities/clients/base/views/record/record.js) I use in the Opportunities controller:

    ({
        extendsFrom: 'RecordView',
       
        initialize: function(options) {
            // antes da 7.9
            app.view.invokeParent(this, {type: 'view', name: 'record', method: 'initialize', args:[options]});   
            // a partir da 7.9 (o invokeParent agora é obsoleto/deprecated na versão 7.9)
            //this._super('initialize', {type: 'view', name: 'record', method: 'initialize', args: [options]});

            console.log('Initialize record.js - Opportunities');

            //add listener for custom button
            this.context.on('button:validate_postal_code:click', this.validate_postal_code, this);
            this.context.on('button:imprime_acordo_comercial:click', this.imprime_acordo_comercial, this);       
            this.on('render', _.bind(this.hide_subpanel, this)); 
        },
       
        validate_postal_code: function() {
            //example of getting field data from current record
            var AcctID = this.model.get('id');
            app.router.navigate('#bwc/index.php?module=Opportunities&action=sugarpdf&sugarpdf=basicinfo&id=' + AcctID + '&type=proposta', {trigger:true});

            //não funciona corretamente
            //window.location.href = 'index.php?module=Opportunities&action=sugarpdf&sugarpdf=basicinfo&id=' + AcctID + '&type=proposta';
            //window.top.SUGAR.App.bwc.login("index.php?module=Opportunities&action=sugarpdf&sugarpdf=basicinfo&id=" + AcctID + "&type=proposta");
        },
       
        imprime_acordo_comercial: function() {
            var AcctID2 = this.model.get('id');
            app.router.navigate('#bwc/index.php?module=Opportunities&action=sugarpdf&sugarpdf=basicinfo&id=' + AcctID2 + '&type=acordo', {trigger:true});
          
            //não funciona corretamente
            // window.location.href = 'index.php?module=Opportunities&action=sugarpdf&sugarpdf=basicinfo&id=' + AcctID2 + '&type=acordo';
        },
        hide_subpanel: function() {
            // tivar validação de campos       
            //removeFromValidate('EditView','entlist_c');
           
            var linkName = 'revenuelineitems';
            var subpanelCollection = this.model.getRelatedCollection(linkName);
            console.log(subpanelCollection);
           
            // A princípio removeria não só o layout, mas também as validações?
            subpanelCollection.remove();
           
            // esconder subpanel
            // subpanel.hide();
        }
    })
  • Initially you have to extends the existing modules/Opportunities/clients/base/views/record/record.js in order to load the default OpportunitiesRecordView behavior, unless you want to fully skip that, which is not a good idea.

    Then you have to replace "

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

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

    Additionally I highly recommend you to convert entryPoints to endPoints once entryPoints will be removed very soon.

    Regards

    André Lopes
    Lampada Global
    Skype: andre.lampada