Tuesday, March 26, 2013

Clear all checkboxes from a specific Tab in javascript - CRM 2011

I had an request that when an option field is changed to a specific value I had to clear all checkboxes found in a specific Tab. So I did this function:


function clearTabCheckboxes(tabName) {
   
    //get tab
    var tab = Xrm.Page.ui.tabs.get(tabName);
   
    tab.sections.forEach(function (section, sectionIndex) {
        section.controls.forEach(function (control, controlIndex) {

            switch (control.getAttribute().getAttributeType()) {
                case "boolean":
                    //for checkbox control, uncheck it
                    control.getAttribute().setValue(false);
                    break;
            }
        });
    });
}

Hope this helps somebody else.

No comments:

Post a Comment