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.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s