Monday, June 27, 2011

MSCRM 4.0: Hide Entity Navigation Bar Items

A client recently asked: How can I hide left navigation bar items within a Contact or Account?:

You have two options to be able to hide left navigation bar items inside a form:

1. Remove all privileges linked to these items in the security roles

2. Add onLoad javascript to force the items not to display

The security role method is very straightforward, however if you have dozens of security roles, this can be time-consuming.

To use javascript, see the below example:

Example: Hide the 'Sub Contacts' menu option inside the Contact entity

* Open a Contact in Microsoft CRM
* With the Contact open, press Ctrl + N to open in a new window
* In Internet Explorer Click View > Source

When the HTML opens in Notepad, search for Sub-Contacts. When it is located, notice that just before the highlighted text you will see: id="navSubConts", write this down.

* Click Settings > Customization > Customize Entities
* Double-click the Contact entity > click Forms & Views
* Double-click Form (Main application form)
* In the right-hand pane, Click Form Properties
* Click OnLoad and Click Edit
* Paste the following Javascript in the box:

document.getElementById("navSubConts").style.display = "none";

* Check the Enable Event checkbox
* Click Save & Close > click Publish

Open a Contact in CRM and the Sub-Contacts menu option should be gone. This same method can be used to hide other entity menu options.

No comments: