Adding Custom Color Flag Fields in Salesforce

Salesforce no longer allows you to create custom fields with custom background colors. However, you can add images to custom fields. Let’s say you wanted to create a custom field to identify case age in business hours. For this example, we’ll identify a case opened within 24 hours with a green flag, a case opened within 48 hours with a yellow flag and a case opened longer than 48 hours with a red flag.
You’ll need to create a customer formula field with a Text return type. The code below will add the flag icons along with the number of hours the case has been opened.

IF(FLOOR((NOW() - CreatedDate)*24) < 24,
IMAGE("/img/samples/flag_green.gif", TEXT(FLOOR((NOW() - CreatedDate))*24)) & " " & TEXT(FLOOR((NOW() - CreatedDate)*24)),
IF(FLOOR((NOW() - CreatedDate)*24) < 48,
IMAGE("/img/samples/flag_yellow.gif", TEXT(FLOOR((NOW() - CreatedDate)*24))) & " " & TEXT(FLOOR((NOW() - CreatedDate)*24)),
IMAGE("/img/samples/flag_red.gif", TEXT(FLOOR((NOW() - CreatedDate)*24))) & " " & TEXT(FLOOR((NOW() - CreatedDate)*24))))

Once you’ve created your custom formula field, add it to a view and you should have a view similar to the image below:

Color Flags in Salesforce

Leave a Reply

Your email address will not be published. Required fields are marked *

Please Do the Math