Wednesday, 13 December 2017

{Know-How} MSCRM JS - show or hide Navigation items using display name or Label



Code Snippet to show or hide a navigation using display name

Function to show or hide Navs
ToggleNavigationItem = function (navName,isVisible) {
    var navs = Xrm.Page.ui.navigation.items.get();
    for (var i in navs) {
        var nav = navs[i];
        if (nav.getLabel() === navName) {
            nav.setVisible(isVisible);
        }
    }
};

Usage
ToggleNavigationItem("Accounts",false); //Hide
ToggleNavigationItem("Accounts",true); //Show

Note: The labels are case sensitive

Contact Form

Name

Email *

Message *