I want to use custom validation in Accounts Module

Hello All,

I want to use custom validation for Accounts Module in sugar 7.7 version

Also i want to display custom message for that validation.

As i am very new to sugar can anyone please help me out.

Regards

Syed Sharif

Parents Reply
  • Hi Sayad Sharif

    If you want to use custom validation with custom message to do so:

    /<>/custom/modules/Accounts/clients/base/views/create/create.js

    Under initialize function add your custom validation as :

    app.error.errorName2Keys['custom_error_message'] = 'Your error message text';
    this.model.addValidationTask('check_your_field_name', _.bind(this._doCustomValidate, this));
    

    Outside of initialize function you need to write your _doCustomValidate function, to do so:

    _doCustomValidate: function(fields, errors, callback) {
      console.log("Am in _doCustomValidate"); 
      // Here you can write your custom validation script code
      if((!_.isEmpty(this.model.get("your_field_name"))))
      {
      errors['your_field_name'] = errors['your_field_name'] || {};
      errors['your_field_name'].custom_error_message = true;
      }
      callback(null, fields, errors); 
    }
    

    Hope this Helps

    Best Regards

    S Ramana Raju

Children