With a simple Dynamics 2011 CRM form I am trying to hide a tab and or it's sections from the onload event. I can successfully step through the code and I get no error but yet the tab is always visible. It's as if my code works and then other built in code reset's it to visible again. There is no other custom code on this form.
function onLoad() {
debugger;
try {
var formType = Xrm.Page.ui.getFormType();
var myTab = Xrm.Page.ui.tabs.get("document");
if (formType == 1) {
var mySec = myTab.sections.get("documentInstructionSection");
mySec.setVisible(true);
mySec = myTab.sections.get("documentDetailsSection");
mySec.setVisible(false);
myTab.setVisible(false);
Xrm.Page.ui.tabs.get("document").setVisible(false);
}
else {
var mySec = myTab.sections.get("documentInstructionSection");
mySec.setVisible(false);
mySec = myTab.sections.get("documentDetailsSection");
mySec.setVisible(true);
}
}
catch (err) {
}
}