How to hide ‘Activities’ and ‘Closed Activities’ from custom entity forms in Dynamics CRM 2011

A common requirement for some Dynamics CRM implementations is to hide navigation items in the left navigation pane on any entity form.

Here’s the problem, you won’t have any issues doing that for system entities, the system allows you to remove ‘Activities’ and ‘Closed Activities’ using the forms’ customisation window.

invoice_with_activities_remove

However, you will notice on custom entities, that you don’t actually get the option to remove activities at all.

class_category_customizations

The fix

Load the following JavaScript snippet code to programmatically set the visibility to false for theActivities’ and ‘Closed Activities’ buttons.

function HideNavigationActivities() {
    Xrm.Page.ui.navigation.items.forEach(function (item, index) {
        var itemLabel = item.getLabel();
        if (itemLabel == "Activities" || itemLabel == "Closed Activities") {
            item.setVisible(false);
        }
    });
}
forms_customizations_onload

The result

class_category_no_activities