Thursday, May 27, 2010

Collapse Sections in CRM 4.0

Here's some code that will collapse sections on CRM 4.0.


/*Function figures out if id of element is a GUID.  Useful for collapsing sections*/
crmForm.DC_IsGUID = function(expression)
{
if (expression != null)
{
var pattern = /^(\{{0,1}([0-9a-fA-F]){8}-([0-9a-fA-F]){4}-([0-9a-fA-F]){4}-([0-9a-fA-F]){4}-([0-9a-fA-F]){12}\}{0,1})$/;
return(pattern.test(expression));
}
return false;
}

crmForm.DC_ToggleSection = function(element, open) {
while(!crmForm.DC_IsGUID(element.id)) {
element = element.parentNode;
}
if(open) {
element.style.display = "block";
}
else
{
element.style.display = "none";
}
}


Happy coding...

No comments:

Post a Comment