Dynamics CRM 2011 · Javascript

CRM 4.0 Disable field using JavaScript

To disable field in CRM form using JavaScript:

crmForm.all.new_field.disabled = 'true';

Ryan Farley has a great detailed post here.

Cheers – Sy

Advertisements

8 thoughts on “CRM 4.0 Disable field using JavaScript

  1. Hello,

    I am pretty new to CRM and am in need of some help. I want to write this code above for an onChange event. I would like to be able to state:

    If new_setappointmnet equals no (bit field)

    crmForm.all.new_appointmenttype.disabled = true;

    If new_setappointment equals yes

    crmForm.all.new_appointmenttype.disabled = false;

    Can anyone help me write this code?

    And I believe the code goes in the onChange event of new_appointmenttype, is that correct?

    Thank you for your help.

    Dylan

    1. Hi Dylan,

      To do this simply use

      if (crmForm.all.new_appointmenttype.DataValue == 1) 
      {
         crmForm.all.new_appointmenttype.disabled = false;
      }
      else
      {
         crmForm.all.new_appointmenttype.disabled = true;
      }
      

      If I’m not mistaken Yes=1 and No=0.

      Also, don’t forget to also handle this for Form OnLoad event. It will improve user experience.

      Cheers,
      Sy

  2. Hi sliong i hope you can read this message… How i cant switch between enabled and disabled by other filed like a checkbox? thanks if you can help me and thenks for you attention anyway

      1. Hi Daniel,

        Apologies for taking so long. If you have solved the issue, that’s great. Otherwise, you may have to work directly to the HTML field objects. But beware that this is unsupported customization.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s