CRM Crate

In this course, we will learn how to hide and show tabs and sections using JavaScript in Dynamics CRM. Before we start make sure to go through the below links.

In Microsoft Dynamics 365, you can hide and show sections and tabs using JavaScript. This is possible by using the “setVisible” property of formContext.

JavaScript for hide/show tab on entity form

Firstly, in the form editor, select the tab which you want to hide show and click on “Change Properties”.

JavaScript for hide/show tab on entity form

Here we can find the tab name as shown below.

Hide / Show tabs using JavaScript

Now lets add the code to the change event of the Ticker Symbol to show the tab when the Ticker Symbol is populated, else hide it.

function TickerChange() {
   if(Xrm.Page.getAttribute("tickersymbol").getValue() == null) {
       Xrm.Page.ui.tabs.get("DETAILS_TAB").setVisible(false);
   }
   else {
       Xrm.Page.ui.tabs.get("DETAILS_TAB").setVisible(true);
   }
}

Now in CRM, when the Ticker Symbol is populated in the form, then the tab is been displayed.

crm crate
crm crate

As soon as the field Ticker Symbol is blank, the tab is hidden out from the form.

crm crate

JavaScript for hide/show section on entity form

We can do the same show/hide with sections. If we want to show or hide the Contact Preferences section, first we have to find the name of that section in the form editor by selecting the section and clicking on Change Properties.

crm crate
crm crate

Below is the JavaScript code for hiding the sections on form using the same above used logic.

function TickerChange() {
   if(Xrm.Page.getAttribute("tickersymbol").getValue() == null) {
       Xrm.Page.ui.tabs.get("DETAILS_TAB").sections.get("CONTACT_PREFERENCES").setVisible(false);
   }
   else {
       Xrm.Page.ui.tabs.get("DETAILS_TAB").sections.get("CONTACT_PREFERENCES").setVisible(true);
   }
}

Now in the CRM record, if the Ticker Symbol is blank, the section will be hidden by the JavaScript code.

crm crate

Once, the field Ticker Symbol is populated, the section will be shown by the JavaScript code.

crm crate

CRM Crate

All In One Platform For Learning Microsoft CRM.

Facebook
Twitter
LinkedIn
error: CRM Crate Security Engine - Disabled Right Click & Selection!

Congratulations!

Well Done,
Welcome to CRM Crate

Stay tuned with us and get all latest updates and learning in Microsoft CRM and related techonologes.