donderdag 12 juni 2008

Hiding custom buttons in CRM 4.0 Toolbar

In CRM 3 it was possible to hide a button on a toolbar just by calling the document.getElementById("").style.display = "none" method.

This will NOT work in CRM 4.0. The ID of the button seems to be generated when the CRM Form is loaded. One time it might be ISV_New_1_MyButtonID the other time it might be ISV_New_39_MyButtonID.

A simple workarround is by checking all the LI items in the UL of the MenuBar and by comparing its ID with "MyButtonID".
To do so use the following javascript in the forms OnLoad event:



var ULListItems = document.getElementById("mnuBar1").rows[0].cells[0].getElementsByTagName("UL")[0].getElementsByTagName("LI");
for(var i=0; i -1)
{
ULListItems[i].style.display = "none";
}
}

Geen opmerkingen: