Coloured Priority Options on Activities Dynamics CRM 2011

Paul Nieuwelaar, 04 March 2012

In Dynamics CRM 2011 by default every Activity entity, including Tasks, Appointments, Phone Calls, and Emails have a ‘Priority’ Option Set which contains 3 options; Low, Normal, and High. This is just using a standard CRM Option Set, where the default option is ‘Normal’.

Coloured Priority Options on Activities Dynamics CRM 2011

This looks a little bit plain and boring by itself, so I wanted to spice it up a little by applying a colour scheme to the options. We’ve heard of Conditional Formatting in Dynamics CRM 2011 for Outlook; however I wanted to do something like this on our Priority fields on activity forms. We would want our users to be able to open an activity, and instantly see if it is high priority or not.

The idea is simple. Low Priority should be coloured as Green, Normal coloured as Yellow, and High as Red. With this in mind it was just a matter of compiling some Javascript to achieve this task. After a bit of investigation, I found quite a simple method of achieving this (all be it unsupported). I’ve put it together in a function that can be used multiple times over different entities, and even different fields (provided they follow the same 3-option structure, using a default value).

I’ve added a snippet of the full function below. This should be added into a JScript Web Resource, and then called on the onLoad of each activity you want this applied to. Simply pass the priority field schema name as a parameter into the event handler.

// Colour a 3 Option Picklist to have Green, Yellow, and Red options
function colourOptionSetValues(field) {
    var picklist = document.getElementById(field); // Get the picklist 
    var option1 = picklist.options[0]; // Value 1
    var option2 = picklist.options[1]; // Value 2
    var option3 = picklist.options[2]; // Value 3 

    option1.style.backgroundColor = "#5EFB6E"; // Change colour to Green if '1'
    option2.style.backgroundColor = "#FFF380"; // Change colour to Yellow if '2' 
    option3.style.backgroundColor = "#E55451"; // Change colour to Red if '3'
}

   Coloured Priority Options on Activities Dynamics CRM 2011

Once your events have been configured, publish your entities and then open an activity. You will instantly see the current priority has a coloured background. If you click the option set drop down, you will also see the colours for each item in the list. If your Priority is set to High, when you reload the activity the field will be red by default.

Coloured Priority Options on Activities Dynamics CRM 2011

This same function can be used across all your activities, or any other entities that you want to use the functionality on. When you’re users are opening activities now they will easily be able to see what the priority is, and it will stand out a lot more if it is High priority.