Show/Hide Navigation Using JScript in CRM

Name Type Description
navItemSchemaName String Provide Navigation Schema name (starts with nav keyword).
Example: navAudit, navDocument etc
VisibleType String Provide Yes (true) or No (false) to Show or Hide Navigation
function showHideNavigation(navItemSchemaName, VisibleType) {
    var objNavItem = Xrm.Page.ui.navigation.items.get(navItemSchemaName);
    if (objNavItem != null) {
        if (VisibleType == "No")
            objNavItem.setVisible(false);
        else if (VisibleType == "Yes")
            objNavItem.setVisible(true);
    }
}

Example:Hide Audit History Navigation in Lead

Solution:Follow the below Steps,
Click on F12 to open Developer Tools and find for the id of Audit History

Hide Audit History

Include the below Code in Javascript Webresource and call in Onload.

function hideAuditHistoryNav() {
    showHideNavigation("navAudit", "No");
}

function showHideNavigation(navItemSchemaName, VisibleType) {
    var objNavItem = Xrm.Page.ui.navigation.items.get(navItemSchemaName);
    if (objNavItem != null) {
        if (VisibleType == "No")
            objNavItem.setVisible(false);
        else if (VisibleType == "Yes")
            objNavItem.setVisible(true);
    }
}

Output:

Please provide your valuable comments on this article.