Posts Tagged ‘disable section’

Disabling controls in a section using JScript

We can’t disable a Section using “setDisabled(false)”, as Section is a container of controls.

Below is the logic to disable all the controls in a section

  • Loop through all the page controls
  • If the control’s parent is the specified section, disable the control

Below are the functions to disable controls in a Section. We need to pass “Section” object as parameter

function disableSectionFields(section) {

if (section) {

Xrm.Page.ui.controls.forEach(function (control, index) {

if (control && doesControlHaveAttribute(control)) {

if (control.getParent() === section) {







// Validate if the control is not  IFrame/webresource/subgrid as we can’t disable them

function doesControlHaveAttribute(control) {

var controlType = control.getControlType();

return controlType != “iframe” && controlType != “webresource” && controlType != “subgrid”;


// Get the Section object by Tab name & Section name

function getSection(tabName, sectionName) {

var tab = Xrm.Page.ui.tabs.get(tabName);

if (tab) {

return tab.sections.get(sectionName);


return null;


How do I call

  • Assume my tab name is “tab_name” & section name is “section_name”
  • Get the section object and pass to the “disableSectionFields” function as below

var mySection = getSection(“tab_name”, “section_name”);

if (mySection) {