Monday, March 1, 2010

Hide left hand nav links

Hello Gang,

This post is about hiding left hand nav links. Every once in a while I get asked to hide certain navigation links based on user interaction or values on a form. Here's the process:

  1. Identify the DOM element that we need to hide
  2. Create function to toggle DOM element
  3. Fire function when the form loads
To find the element id that we need to hide you can do one of two things:
  1. Find the relationship name in the relationship section of the customizations editor. You will have to prefix "nav_" to this relationship name
  2. Open the form in question, press Ctrl-n, and dig around in the source until you find the appropriate DOM element id.
Here's the code:

crmForm.Neudesic_HideNavObligor = function() {

/*get value of checkbox*/
var value = crmForm.all.neu_obligor.DataValue;
var display = "none";
if(value) {
display = "block";
try {
/*this will fail on preview as the left hand menu is not generated*/
var element = document.getElementById("nav_neu_obligor_neu_settlement"); = display;
}catch(error) {

/*attach event*/
if(crmForm.FormType == 1 || crmForm.FormType == 2) {

crmForm.all.neu_obligor.attachEvent("onclick", crmForm.Neudesic_HideNavObligor);
/*fire event when the form opens*/

No comments:

Post a Comment