Cry about...
Dynamics CRM 2011 How To


How to hide or show a field using JavaScript


Dynamics CRM 2011 forms are organized in tabs. Each tab contains sections which in turn contain fields.

The "Field Properties" dialog (which is accessible inside the form designer of Dynamics CRM 2011) lets you specify whether a field is visible (or hidden) by default.

By adding JavaScript to an event handler you can hide or show a field in code. You need to know the name of the fieldand then to show the field is simply:

Xrm.Page.ui.controls.get("field_name").setVisible(true);

or to hide the field:

Xrm.Page.ui.controls.get("field_name").setVisible(false);

Substituting your own field-name in the above.

Be aware that hiding or showing a field does not affect whether the section or tab containing the field is visible. So you might want to combine the above with logic to hide or show the containing tab and section.


You can also show and hide sections and fields, see:


These notes have been tested with Microsoft Dynamics CRM 2011, and may apply to other versions as well.



About the author: is a dedicated software developer and webmaster. For his day job he develops websites and desktop applications as well as providing IT services. He moonlights as a technical author and consultant.