Sugar 7.8.2.0 is not working this.model.get('field_name')

Hi All,

Sugar 7.8.2.0 is not working this.model.get('field_name').

custom/modules/Accounts/clients/base/views/record/record.js

console.log( this.model.get('website') + '---'); 

it's return "undefined".

/**
* @class View.Views.Base.Accounts.RecordView
* @alias SUGAR.App.view.views.BaseAccountsRecordView
* @extends View.Views.Base.RecordView
*/
({
     // CustomRecord View (base)

    extendsFrom: 'RecordView',

    /**
     * @inheritdoc
     */
    initialize: function(options) {
        this.plugins = _.union(this.plugins || [], ['HistoricalSummary']);
        this._super('initialize', [options]);
    },
    _render: function() {
        this._buildGridsFromPanelsMetadata(this.meta.panels);
        if (this.meta && this.meta.panels) {
            this._initTabsAndPanels();
        }

        app.view.View.prototype._render.call(this);

        if (this.context.get('record_label')) {
            this.setLabel(this.context, this.context.get('record_label'));
        }
        console.log('Asif call' + this.model.id);
     console.log( this.model.get('website') + '---');
       
        // Field labels in headerpane should be hidden on view but displayed in edit and create
        _.each(this.fields, function(field) {
            // some fields like 'favorite' is readonly by default, so we need to remove edit-link-wrapper
            if (field.def.readonly && field.name && -1 == _.indexOf(this.noEditFields, field.name)) {
                this.$('.record-edit-link-wrapper[data-name=' + field.name + ']').remove();
            }
        }, this);

        if (this.action === 'edit') {
            this.setButtonStates(this.STATE.EDIT);
            this.toggleEdit(true);
        } else {
            this.setButtonStates(this.STATE.VIEW);
            if (this.createMode) {
                this.toggleEdit(true);
            }
        }

        // initialize tab view only if the component is attached to DOM,
        // otherwise it's initialized partially and cannot be properly
        // re-initialized after the component is attached to DOM
        if ($.contains(document.documentElement, this.$el[0])) {
            this.handleActiveTab();
            this.overflowTabs();
        }
    },
})

Asif

Offshore Evolution Pvt. Ltd.

Francesca Shiekh Ramana Raju Santhana Hiren Darji

Parents
  • Hi Offshore Evolution 

    Why calling "app.view.View.prototype._render.call(this);" instead of "this._super('_render', []);"?

    Maybe this is the issue behind.

    Additionally you can extends from BaseAccountsRecordView the way you don't need to fully copy the method initialize.

    Regards

    André Lopes
    Lampada Global
    Skype: andre.lampada
  • In 7.8 there were some changes in how views are rendered. 

    You may have noticed that the page comes up first, then the data populates.

    I can't seem to find the documentation on this change, but, if I recall correctly, the render of the form is completed BEFORE the data is retrieved, and therefore the data is not available in _render.

    See if you can achieve your goal by adding your code after the sync.

    In your initialize:

        this.model.once('sync', function() {

           this.CustomEvent();

        }, this);

    Once the model is sync'd you have the data and you can work with it.

    HTH

    FrancescaS

    PS. Found it!

    http://support.sugarcrm.com/Documentation/Sugar_Versions/7.8/Pro/Sugar_7.8.0.0_Release_Notes/ 

    in the Development Changes section:

    • The Sugar record view (RecordView) was being rendered twice on each page load. This performance issue has been corrected. Now the record view renders once and the individual field components are re-rendered when data is available. Sugar Developers should test their record view customizations to ensure this does not introduce any regressions in code that relied on this behavior. Specifically, Developers should test any custom Sidecar code which relies on field data being available during record view render, since it will likely break as the views are rendered before fields.
Reply
  • In 7.8 there were some changes in how views are rendered. 

    You may have noticed that the page comes up first, then the data populates.

    I can't seem to find the documentation on this change, but, if I recall correctly, the render of the form is completed BEFORE the data is retrieved, and therefore the data is not available in _render.

    See if you can achieve your goal by adding your code after the sync.

    In your initialize:

        this.model.once('sync', function() {

           this.CustomEvent();

        }, this);

    Once the model is sync'd you have the data and you can work with it.

    HTH

    FrancescaS

    PS. Found it!

    http://support.sugarcrm.com/Documentation/Sugar_Versions/7.8/Pro/Sugar_7.8.0.0_Release_Notes/ 

    in the Development Changes section:

    • The Sugar record view (RecordView) was being rendered twice on each page load. This performance issue has been corrected. Now the record view renders once and the individual field components are re-rendered when data is available. Sugar Developers should test their record view customizations to ensure this does not introduce any regressions in code that relied on this behavior. Specifically, Developers should test any custom Sidecar code which relies on field data being available during record view render, since it will likely break as the views are rendered before fields.
Children