AnsweredAssumed Answered

Sugar Enterprise 7 - Client-side validation not working

Question asked by Ramon Marcondes on May 19, 2016
Latest reply on May 19, 2016 by Tevfik Tümer

Hello.

I'm using Sugar Enterprise 7.5.2.4.

I have a RevenueLineItems module, and need some validations for field and form submit.

I have a record.js file for the module, with its destination path defined in the manifest installdefs as: custom/modules/RevenueLineItems/clients/base/views/record/record.js

 

// Manifest file

2 => array(

                'from' => '<basepath>/Files/custom/modules/RevenueLineItems/clients/base/views/record/record.js',

                'to' => 'custom/modules/RevenueLineItems/clients/base/views/record/record.js',

            ),

This is the record.js logic:

 

({   
    extendsFrom: 'RevenueLineItemsRecordView',   
    events: {
        'submit form': 'submit'
    },
  
    initialize: function (options) {    
        this._super('initialize', [options]); 
        //add custom message key   
        //app.error.errorName2Keys['custom_message'] = 'ERR_CUSTOM_MESSAGE';
        //add validation  
        console.log("initialize");         
    },   
    submit: function (options) {    
        this._super('submit', [options]); 
        //add custom message key   
        //app.error.errorName2Keys['custom_message'] = 'ERR_CUSTOM_MESSAGE';
        //add validation  
        console.log("submit");
        this.model.addValidationTask('check_account_type', _.bind(this._doValidateCheckType, this));         
    }, 
    _doValidateCheckType: function(fields, errors, callback) {  
        //validate requirements
        console.log("function submit");
        
        /*
        if (this.model.get('account_type') == 'Customer' && _.isEmpty(this.model.get('phone_office'))) {
            errors['phone_office'] = errors['phone_office'] || {}; 
            errors['phone_office'].custom_message = true;
        }
        callback(null, fields, errors);
        */
    }
})

 

What I want to know is: why this is not working?

It's not even printing on the console. Do the backbone.js framework that Sugar Enterprise client validation uses doesn't even support a 'console.log'?

 

I followed the tutorial:

http://support.sugarcrm.com/Knowledge_Base/Developers/Customization/Handling_Validation_Task_Errors/index.html

And still no luck.

What I'm doing wrong?

 

Any help would be appreciated.

Thanks.

Outcomes