SugarCRM: Create a custom javascript validation before saving in Edit view

sugarcrmdevelopers —  April 4, 2013

This note will teach you how to call a custom javascript function upon clicking the Save button in Edit view.

1. Create a custom view.edit.php in custom/modules//view/ and create the javascript function under the preDisplay function. See sample code bellow:

public function preDisplay() {

// Javascript function to call

function customJavascriptValidation() {

// Insert code here

return check_form(“Edit View”); // This will call the default function that sugar use


2. Go tot editviewdefs.php in custom/modules/metadata/ and put the codes below before the widths array:

'form' =>
      array (
        'buttons' =>
        array (
          0 => array (
            'customCode' => '',

* if file doesnt exist then copy the ediviewdefs.php from modules/metadata/

3. Run Quick Repair and Rebuild.