Sunday, March 27, 2011

MSCRM 4.0: Changing Background Colors on Entity Forms

A customer recently asked: I’d like to change the color of some fields on the Account form to highlight that it is a required field. Also, I’d like to change the color of the address section to make it stand out on the form.

Following is the code to be added to the On_load event of the Account form:

// Code to Change Color of Account Name Field
crmForm.all.name.style.backgroundColor = "#FF00F"; crmForm.all.name_c.style.backgroundColor = "#FF00FF";
// Code to Change Color of Address Section
crmForm.all.address1_name_c.parentElement.parentElement.parentElement.style.backgroundColor = "#87cefa";

A good website resource for getting the html codes for specific colors: http://www.december.com/html/spec/color.html