How to add colour to a Microsoft CRM Form Picklist
Posted @ 6/9/2010 4:36 PM by Emma | Files in Microsoft Dynamics CRM 2011,CRM 2011
I recently got asked by a customer to change the colours of Service Cases based on their priority. P1 = Red, P2 = Yellow, and P3 = Green. Whilst there is no standard capability within Microsoft CRM to perform this on Case Lists or Case Form, there is a form script which can be added to the Form OnLoad() to perform the change.
The colours are present within the picklist dropdown.

Upon selecting a value the picklist colour is then maintained on the form view.
The code required to make the above changes is as follows;
// Get the picklist
var picklist = crmForm.all.contractservicelevelcode;
// Change colour to Red if P1
var option = picklist.options[1];
option.style.backgroundColor = "#E55451";
// Change colour to Yellow if P2
var option = picklist.options[2];
option.style.backgroundColor = "#FFF380";
// Change colour to Green if P3
var option = picklist.options[3];
option.style.backgroundColor = "#5EFB6E";