Converting to CRM 2011 JavaScript: Showing and Hiding form elements

Let’s face it: we all did unsupported customizations with our CRM 4.0 JavaScript in order to present to the user an interface that was contextually relevant. Most of that modification involved the showing and hiding of fields, sections, and tabs through the DOM manipulation by setting the .style property to either show or hide things.

We Dynamics CRM 2011, we have an object model that supports the showing and hiding of:

  • Tabs
  • Sections
  • Fields
  • Navigation items

by using code similar to this:




Note: There is also a corresponding .getVisible method that gets the visibility state of an item.

So, when you are upgrading your code, you need to convert any instance of:

// Hide fields"hidden"; = 'none'; = 'none'; 

// Show fields"visible"; = 'inline'; = 'inline';



// Hide fields

// Show fields

This is also something that the CRM Migration Assistant handles quite nicely.


One final note:

In the samples above, you will see the use of field names that end with “_c” and “_d.”  These are the field label and field edit box respectively.

When converting your code, you will need to delete one of the lines of code, like the one that shows/hides the “_d” field, and remove the “_c” from the field name so that you code looks like this:



We do this because CRM would throw an error if you attempted to hide the “partial” field.

Leave a Reply 1 comment