In this blog, we will understand how to show/hide section using JavaScript in D365 CE(CRM).
Syntax to get the section object:
let tabObj = formContext.ui.tabs.get("tabNameInWhichSectionIsPresent");
let sectionObj = tabObj.sections.get("sectionName");
Syntax to show/hide section:
sectionObj.setVisible(bool);
PARAMETER:

Code:
var formCustomizations = {
projectTaskSection: function (executionContext) {
let formContext = executionContext.getFormContext();
let showTaskValue = formContext.getAttribute("crff1_showtask").getValue();
let tabObj = formContext.ui.tabs.get("{eb0bd2f5-9b61-4671-a9d6-4c75988ed11b}");
let sectionObj = tabObj.sections.get("{eb0bd2f5-9b61-4671-a9d6-4c75988ed11b}_section_2");
if (showTaskValue != null && showTaskValue == 267460000) {
//show the section
sectionObj.setVisible(true);
}
else {
//hide the section
sectionObj.setVisible(false);
}
}
}
Explanation:
- To get the section object we have to get the tab object in which the section is present.
- To get the tab name click on that and check the properties

- To get the section name click on that and check the properties

Result:

