Javascript to hide a section on a CRM form

In CRM, when you want to use Javascript to hide a section on a form (a section - not a tab), you can do it, but when you Google search it you will find various examples of how to do it.

But the simplest is probably doing it this way:

Step 1 - find a field on the form that is in the section you want to hide

In our example, we have a field called "new_orderpadmonthlyfee" that is in the section we want to hide.

Step 2 - have Javascript hide the section you want by referencing the field on the form:

Xrm.Page.getControl("new_orderpadmonthlyfee").getParent().setVisible(false);

This example was obtained from Microsoft's web site:

http://msdn.microsoft.com/en-us/library/jj602964.aspx#BKMK_AccessingAttributes

NOTE: the other examples you may find on the internet get tricky because you have to try to reference the "name" of the section you want to hide. And it is unclear what name to use. So the above gets around that problem.

Developed for CRM 2011.