Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

CRM 2011 HideTab

Posted on by Microsoft Employee

Hello-

I am working in CRM2011.  I created a custom form with 9 tabs.  2 tabs will be visible always and I want to hide 7 tabs on load.  Of the 7 I only wabt tabs to be visible based on a selected picklist value.  I wrote the below code but it is not working.  It is OnLoad and OnChange event. Error 'tab_1' is undefined.

function hideTabSection() {
    if (Xrm.Page.getAttribute("cpdc_requesttype").getSelectedOption() == null) {
        Xrm.Page.ui.tabs.get("tab_1").setVisible(false);
        Xrm.Page.ui.tabs.get("tab_4").setVisible(false);
        Xrm.Page.ui.tabs.get("tab_6").setVisible(false);
        Xrm.Page.ui.tabs.get("tab_7").setVisible(false);
        Xrm.Page.ui.tabs.get("tab_8").setVisible(false);
        Xrm.Page.ui.tabs.get("tab_9").setVisible(false); 
        Xrm.Page.ui.tabs.get("tab_10").setVisible(false);         

    } else {
        var option = Xrm.Page.getAttribute("cpdc_requesttype").getSelectedOption().text;
        if (option == "Add/Edit Internal Event") {
            Xrm.Page.ui.tabs.get("tab_1").setVisible(true);
            Xrm.Page.ui.tabs.get("tab_4").setVisible(false);
            Xrm.Page.ui.tabs.get("tab_6").setVisible(false);
            Xrm.Page.ui.tabs.get("tab_7").setVisible(false);
            Xrm.Page.ui.tabs.get("tab_8").setVisible(false);
            Xrm.Page.ui.tabs.get("tab_9").setVisible(false); 
            Xrm.Page.ui.tabs.get("tab_10").setVisible(false);  
        } else if (option == "Lawyer Departure") {
            Xrm.Page.ui.tabs.get("tab_4").setVisible(true);
            Xrm.Page.ui.tabs.get("tab_1").setVisible(false);
            Xrm.Page.ui.tabs.get("tab_6").setVisible(false);
            Xrm.Page.ui.tabs.get("tab_7").setVisible(false);
            Xrm.Page.ui.tabs.get("tab_8").setVisible(false);
            Xrm.Page.ui.tabs.get("tab_9").setVisible(false); 
            Xrm.Page.ui.tabs.get("tab_10").setVisible(false); 
        } else if (option == "Total Bio Change") {
            Xrm.Page.ui.tabs.get("tab_6').setVisible(true);
            Xrm.Page.ui.tabs.get("tab_1").setVisible(false);
            Xrm.Page.ui.tabs.get("tab_4").setVisible(false);
            Xrm.Page.ui.tabs.get("tab_7").setVisible(false);
            Xrm.Page.ui.tabs.get("tab_8").setVisible(false);
            Xrm.Page.ui.tabs.get("tab_9").setVisible(false); 
            Xrm.Page.ui.tabs.get("tab_10").setVisible(false);  
        } else if (option == "Bio Section Change") {
            Xrm.Page.ui.tabs.get("tab_7").setVisible(true);
            Xrm.Page.ui.tabs.get("tab_1").setVisible(false);
            Xrm.Page.ui.tabs.get("tab_4").setVisible(false);
            Xrm.Page.ui.tabs.get("tab_6").setVisible(false);
            Xrm.Page.ui.tabs.get("tab_8").setVisible(false);
            Xrm.Page.ui.tabs.get("tab_9").setVisible(false); 
            Xrm.Page.ui.tabs.get("tab_10").setVisible(false); 
        } else if (option == "PG/IG Capability Change") {
            Xrm.Page.ui.tabs.get("tab_8").setVisible(true);
            Xrm.Page.ui.tabs.get("tab_1").setVisible(false);
            Xrm.Page.ui.tabs.get("tab_4").setVisible(false);
            Xrm.Page.ui.tabs.get("tab_6").setVisible(false);
            Xrm.Page.ui.tabs.get("tab_7").setVisible(false);
            Xrm.Page.ui.tabs.get("tab_9").setVisible(false); 
            Xrm.Page.ui.tabs.get("tab_10").setVisible(false);   
        } else if (option == "New Joiner") {
            Xrm.Page.ui.tabs.get("tab_9").setVisible(true);
            Xrm.Page.ui.tabs.get("tab_1").setVisible(false);
            Xrm.Page.ui.tabs.get("tab_4").setVisible(false);
            Xrm.Page.ui.tabs.get("tab_6").setVisible(false);
            Xrm.Page.ui.tabs.get("tab_7").setVisible(false);
            Xrm.Page.ui.tabs.get("tab_8").setVisible(false); 
            Xrm.Page.ui.tabs.get("tab_10").setVisible(false);  
        } else if (option == "PR News") {
            Xrm.Page.ui.tabs.get("tab_10").setVisible(true);
            Xrm.Page.ui.tabs.get("tab_1").setVisible(false);
            Xrm.Page.ui.tabs.get("tab_4").setVisible(false);
            Xrm.Page.ui.tabs.get("tab_6").setVisible(false);
            Xrm.Page.ui.tabs.get("tab_7").setVisible(false);
            Xrm.Page.ui.tabs.get("tab_8").setVisible(false); 
            Xrm.Page.ui.tabs.get("tab_9").setVisible(false);  
        }
    }
}

*This post is locked for comments

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: CRM 2011 HideTab

    Hi

    Thank you for the advise.  I made the tabs on my form default to closed and then I changed my script to the following.  The tabs now display correctly based on the request type however I get this "error-hideTab is undefined"...Not sure what I am doing to create this, when I clear out error the script functions as I want it to.

    hideTabOnLoad = function() {

    var requesttype = Xrm.Page.getAttribute(“cpdc_requesttype”);

    if (requesttype.getValue() == 100000003) //Add/EditInternalEvent

    {

    Xrm.Page.ui.tabs.get(“tab_1”).setVisible(true);

    Xrm.Page.ui.tabs.get(“Tab_4”).setVisible(false);

    Xrm.Page.ui.tabs.get(“tab_6”).setVisible(false);

    }

    if (eventtype.getValue() == 100000000) //LawyerDeparture

    {

    Xrm.Page.ui.tabs.get(“tab_1”).setVisible(false);

    Xrm.Page.ui.tabs.get(“Tab_4”).setVisible(true);

    Xrm.Page.ui.tabs.get(“tab_6”).setVisible(false);

    }

    if (eventtype.getValue() == 100000001) //TotalBioChange

    {

    Xrm.Page.ui.tabs.get(“tab_1”).setVisible(false);

    Xrm.Page.ui.tabs.get(“Tab_4”).setVisible(false);

    Xrm.Page.ui.tabs.get(“tab_6”).get.setVisible(true);

    }

    if (requesttype.getValue() == null) //Empty

    {

    Xrm.Page.ui.tabs.get(“tab_1”).setVisible(false);

    Xrm.Page.ui.tabs.get(“Tab_4”).setVisible(false);

    Xrm.Page.ui.tabs.get(“tab_6”).setVisible(false);

    }

    }

  • Suggested answer
    jlattimer Profile Picture
    jlattimer 24,558 on at
    RE: CRM 2011 HideTab

    I see a typo - tab_6 has mis-matched quotes - I also assume you are using the tab's "Name" field in the properties.

     } else if (option == "Total Bio Change") {
           Xrm.Page.ui.tabs.get("tab_6').setVisible(true);
           Xrm.Page.ui.tabs.get("tab_1").setVisible(false);


Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,214 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans