I am attempting to hide certain tabs on an Order form based on a field called 'department'. I will attach a screenshot of the error and my code.
function Form_OnLoad() { setDepartmentDisabled(); setFormState(); } function setDepartmentDisabled() { var department = Xrm.Page.ui.controls.get('aai_department'); if (department != null && department != 'undefined') { var formType = Xrm.Page.ui.getFormType(); switch (formType) { case FORM_TYPE_CREATE: department.setDisabled(false); break; default: var value = getSelectedOptionValue(department.getAttribute().getName()); switch (value) { case 100000000: case 100000001: case 100000002: case 100000003: department.setDisabled(true); break; default: break; } break; } } } function setFormState() { var value = getSelectedOptionValue('aai_department'); switch (value) { case 100000000: //Underwriting case 100000001: //Asset Management setVisible(TAB_ZONING, false, requiredFieldsZoning); setVisible(TAB_UNDERWRITING_AND_ASSETMANAGEMENT, true, requiredFieldsUnderwritingAssetManagement); //setVisible(SECTION_CLOSING, false, requiredFieldsClosing); Xrm.Page.getAttribute("new_oversight").setRequiredLevel("required"); Xrm.Page.getAttribute("new_underwriter").setRequiredLevel("none"); Xrm.Page.getAttribute("new_analyst").setRequiredLevel("required"); Xrm.Page.getAttribute("aai_kickoff").setRequiredLevel("none"); Xrm.Page.getAttribute("aai_duedate").setRequiredLevel("none"); Xrm.Page.getAttribute("aai_deliverydate").setRequiredLevel("none"); break; case 100000002: //Zoning setVisible(TAB_ZONING, true, requiredFieldsZoning); setVisible(TAB_UNDERWRITING_AND_ASSETMANAGEMENT, false, requiredFieldsUnderwritingAssetManagement); //setVisible(SECTION_CLOSING, false, requiredFieldsClosing); Xrm.Page.getAttribute("new_oversight").setRequiredLevel("none"); Xrm.Page.getAttribute("new_underwriter").setRequiredLevel("none"); Xrm.Page.getAttribute("new_analyst").setRequiredLevel("required"); Xrm.Page.getAttribute("aai_kickoff").setRequiredLevel("required"); Xrm.Page.getAttribute("aai_duedate").setRequiredLevel("required"); Xrm.Page.getAttribute("aai_deliverydate").setRequiredLevel("none"); break; case 100000003: //Closing setVisible(TAB_ZONING, false, requiredFieldsZoning); setVisible(TAB_UNDERWRITING_AND_ASSETMANAGEMENT, true, requiredFieldsUnderwritingAssetManagement); //setVisible(SECTION_CLOSING, false, requiredFieldsClosing); Xrm.Page.getAttribute("new_oversight").setRequiredLevel("required"); Xrm.Page.getAttribute("new_underwriter").setRequiredLevel("required"); Xrm.Page.getAttribute("new_analyst").setRequiredLevel("none"); Xrm.Page.getAttribute("aai_kickoff").setRequiredLevel("required"); Xrm.Page.getAttribute("aai_duedate").setRequiredLevel("required"); Xrm.Page.getAttribute("aai_deliverydate").setRequiredLevel("none"); break; default: setVisible(TAB_ZONING, false, requiredFieldsZoning); setVisible(TAB_UNDERWRITING_AND_ASSETMANAGEMENT, false, requiredFieldsUnderwritingAssetManagement); //setVisible(SECTION_CLOSING, false, requiredFieldsClosing); break; } } function setVisible(id, value, requiredFields) { if (id != '') { var tab = Xrm.Page.ui.tabs.get(id); tab.setVisible(value); }
*This post is locked for comments