Disable and Enable dropdown on change of another field

By
Last Modified Date

I had to disable and enable a dropdown on check/uncheck of a checkbox field in Sugar 7. I did the following customizations to accomplish the task:

    • First we will need to extend and override record view controller. Record view can be extended following the guidelines in Extending Sugar7 Record View.

custom/modules/<module>/clients/base/views/record/record.js

  • Then in controller file we would need to bind an event on change of checkbox. Place the following code in initialize function
this.model.on("change:my_checkbox", this.DisableEnableDropdown, this);
  • Disable and EnableDropDown function

DisableEnableDropDown: function () {
  if(this.model.get('my_checkbox') != '1')
  {
      $("[data-fieldname=mydropdown] input").select2('disable');
  }
  else
  {
         $("[data-fieldname=mydropdown] input").select2('enable');
  }
}

Once the files are in place, you will need to navigate to Admin > Repair > Quick Repair and Rebuild.

Rolustech is a SugarCRM Certified Developer & Partner Firm. We have helped more than 600 firms with various SugarCRM Customization and Integration. Get in touch today for your FREE Business Analysis. We will be happy to assist you!

Need Help? Get Free Consultation


By clicking you agree to our Terms and Conditions

Send me news and updates

Get in touch


Contact Information