1
votes

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) {

    }
}
1
how many tabs you have inside the form? did you try to access the tab by the index?Guido Preite
Did you ever find a solution to this?Martin Wedvich

1 Answers

0
votes

To resolve your problem, I suggest to do below actions to throubleshoot:

  1. To promise these values are not null: mySec, myTab
  2. Trun off all of JS event on the form except the onload event, and check your codes again.
  3. If above actions still can not resolve it, you can try to use JS DOM to hidden those tabs. Such as document.getElementById("XXX").style.display="none"