« SWOT Analysis in Microsoft CRM | Main | Microsoft India investing in CRM »
Adding color indicators to an entity record
Yesterday, I mentioned a demo that I was preparing for a prospect. Another one of their stated requirements was:
If we wanted to flag a field could that record be in red? Such as customers past due and etc?
This was an easy demo request to accommodate, because I know that we included a nearly identical sample in our upcoming Programming Microsoft Dynamics CRM 4.0 book! The book example actually adds a color indicator on an opportunity record that updates depending on its rating (hot, warm, cold) so I tweaked book's example code for the prospect. I added two custom attributes to the account entity:
- Notification (nvarchar)
- Payment Status (picklist)
Then I added this code to the form onLoad event for the account record, and to the onChange event for the payment status field.
UpdateDisplayBar();
function UpdateDisplayBar()
{
var notificationDisplay = document.getElementById("new_notification_d");
var displayColor = "#EAF3FF";
switch (crmForm.all.new_paymentstatus.DataValue)
{
case "1":
displayColor = "green";
break;
case "2":
displayColor = "red";
break;
}
var displayBar = "<div style='background=" + displayColor + "'> </div>";
notificationDisplay.innerHTML = displayBar;
}
Now when you open an account record and update its payment status field, you'll see a color indicator on the first tab (next to the Payment Status field). Green indicates they are "OK", and red indicates "Overdue". No color indicates that neither value has been selected. This is a sample example, but it gives a flavor of what's possible within the user interface!

Posted by Mike Snyder on September 2, 2008 in Microsoft Dynamics CRM 4.0, Programming Microsoft Dynamics CRM 4.0 Book | Permalink
Comments
Hi Mike
I saw your demo and noticed there is an ownership entity related to your account entity. I am curious about what you use the entity for. Is it used to pass on ownhership from one user to the other? If so, could you share some information about it. I'm looking for something like that for one of my customers in The Netherlands.
Thx, Ralf
By the way, cool to see the color coding in the form.
Posted by: Ralf | Sep 3, 2008 1:40:52 AM
Hi Mike,
Really nice tip.
Is there a way of doing something similar to cases? i.e. when in case view (Whether thats my cases or open cases etc), the lines are color coded (depending on case status or importance).
Rob
Posted by: Robert Peledie | Sep 3, 2008 3:59:52 AM


