Monday, June 22, 2009

Hide Elements on OnLoad in CRM 4.0/CRM 3.0

I know it is pretty simple to do but I see there are posts popping up here and there for the same. So here it is, a very simple script to hide form elements in CRM during page load. You can call the function from any where any time once you have put it on OnLoad event of the page.

document.HideElement = function(elementId) {
if (document.getElementById(elementId))
document.getElementById(elementId).style.display = 'none';
}

And here how you can use this function to hide various elements when CRM form loads

document.HideElement("_MBcrmFormSave"); // Hides Save button
document.HideElement("_MBcrmFormSaveAndClose"); // Hides Save And Close button

to hide an element say for example : AccountValue, following will be the code snippet

document.HideElement("skynet_AccountValue_c");
document.HideElement("skynet_AccountValue_d");
document.HideElement("skynet_AccountValue");