JavaScript Upgrade Gotcha #3: The .style property

There are certain cases where it is necessary to customize the CRM user interface to perform a specific action or to inform the user of a specific condition or alert, or whatever. This was mainly accomplished by changing the .style property of a field.

Such actions were totally unsupported in CRM 4.0 and remain so in CRM 2011. Here are some examples:

crmForm.all[fieldname].style.borderRight = "#3366cc 1px solid";
crmForm.all[fieldname].style.paddingRight = "5px";
crmForm.all[fieldname].style.borderTop = "#3366cc 1px solid";
crmForm.all[fieldname].style.paddingLeft = "5px";
crmForm.all[fieldname].style.fontSize = "11px";
crmForm.all[fieldname].style.fontWeight = "bold";
crmForm.all[fieldname].style.backgroundImage = "url(/_imgs/btn_rest.gif)";
crmForm.all[fieldname].style.borderLeft = "#3366cc 1px solid";
crmForm.all[fieldname].style.width = buttonwidth;
crmForm.all[fieldname].style.cursor = "hand";
crmForm.all[fieldname].style.lineHeight = "18px";
crmForm.all[fieldname].style.borderBottom = "#3366cc 1px solid";
crmForm.all[fieldname].style.backgroundRepeat = "repeat-x";
crmForm.all[fieldname].style.fontFamily = "Tahoma";
crmForm.all[fieldname].style.height = "20px";
crmForm.all[fieldname].style.backgroundColor = "#cee7ff";
crmForm.all[fieldname].style.textAlign = "center";
crmForm.all[fieldname].style.overflow = "hidden";

The problem is that some organizations would like these features even though they know they run the risk of incompatibility with a future upgrade.

That being the case, there is an option called Use unsupported customizations which will allow you to choose to use a possibly workable but unsupported solution:

 

Xrm.Page.getControl("new_status")["_control"]["_element"].style.textColor = "#000000";

 

Again, this is unsupported code; it only applies to the .style property and it may not work in the next version of CRM.

The only .style properties which are supported by Transformer! Are:

  • .style.display
  • .style.visibility

These translate into the setVisible method. The remainder will be marked with a Conversion Alert.

 

Need help with your JavaScript upgrade to Dynamics CRM 2011 and 2013?

See what Transformer! for Dynamics CRM can do for you.

Leave a Reply