While customizing a Dynamics CRM 2013 form, you may need to show/hide some fields or sections. Let’s say that in this latest Dynamics CRM version, things are getting easier and we have 2 ways to do so.
First, you may have noticed it, Dynamics CRM 2013 includes a new feature called “Business Rules” (BR) that makes it easier to do some basic operations that we used to implement using code. For example, Business Rules can help you make conditions to show/hide a field (but not an entire section).
To show/hide a section, there are 2 ways:
1-Using BR: Hiding all the fields contained in a section automatically hides the section. This can be used especially when you have few fields in your section.
CAUTION: When a BR is defined, you should create the “else” BR. That means a BR which shows your fields when your condition is verified and a BR which hides them when your condition is not OK.
Xrm.Page.ui.tabs.get(“tabname”).sections.get(“sectioname”).setVisible(true); //Shows a section
Xrm.Page.ui.tabs.get(“tabname”).sections.get(“sectioname”).setVisible(false); //Hides a section