Use Images in Salesforce Formula Fields to Spice up Your Org

Share this article...

One of Salesforce’s most attractive features is the ability to customise anything and everything. Buying an off the shelf product but being able to completely tailor it to your unique business processes is one of the reasons Salesforce is No 1. A feature that has been around for quite some time, is the ability to add images to Salesforce formula fields. This essentially means instead of calculating a number, or outputting a string of text, the formula fields “result”, can be a series of images depending on the scenario. Our friends over at Salesforce Labs have given us some basic images for quite some time, however with the recent overhaul of the Graphics Pack on the AppExchange, we have a whole host of icons to play around with.

If you’ve ever seen an official Salesforce demo, you might notice that they put a huge amount of effort into using images and icons to show different states of records. The reason? It looks a lot more aesthetically pleasing and information can be digested quicker. Let’s look at a few examples where icons can be tremendously helpful in improving the usability and aesthetics of your Org.



1. Account Health Rating – Could be based on last activity date, or other metrics you hold in your Org.

2. Case Status Image – Simply based off of the Case Status to quickly show which cases need attention

3. Lead Score – Can be based on the rating field or a custom lead score field


Now that you’ve seen the power of images, let’s have a look at how to implement them. Before making changes to your Org, I would ask yourself the question, “Where can my users benefit the most from images?”. You don’t want to just start using images for the sake of it, but to help users get a glimpse of the status of their data.

1. Install the Graphics Pack – Using the following link, install the Graphics Pack from Salesforce Labs. This will give you access to pages and pages of icons.

2. Create a Formula Field – The next step is to create a formula field with the output type of Text

3. Prepare your output – Before creating your formula field, it’s a good idea to select the graphics you want to use and prepare the output that you will use. The images displayed are encased in the formula field function IMAGE. This is used in the following method… IMAGE(“Image URL”, “Alt text”). The Image URL is accessible once clicking on any image in the graphics pack, and you need to remember to grab everything after and including “/resource/….”. Alt text is simply a placeholder just in case the image can’t be displayed.

4. Create an IF or CASE Statement – The most common way to use image fields is using an IF or CASE statement. Reason being, you want your image to be dynamic based on data stored in the record. If we take a look at the Lead score examples from above, our case statement looks like this…

CASE(Rating, “Hot”, IMAGE(“/resource/1523798147000/GraphicsPackNew/silk/16/silk/medal_gold_1.png”, “Hot”), 

“Warm”, IMAGE(“/resource/1523798147000/GraphicsPackNew/silk/16/silk/medal_silver_1.png”, “Warm”), 

IMAGE(“/resource/1523798147000/GraphicsPackNew/silk/16/silk/medal_bronze_1.png”, “Cold”))

More Examples

Account Health Rating

CASE(Account_Health__c, “Good”, IMAGE(“/resource/1523798147000/GraphicsPackNew/tangodesktopproject/16/theme/dialog-error.png”, “Red”), 

“Ok”, IMAGE(“/resource/1523798147000/GraphicsPackNew/tangodesktopproject/16/theme/emblem-important.png”, “Orange”), 

IMAGE(“/resource/1523798147000/GraphicsPackNew/fatcow/farmfresh/16/tick.png”, “Green”))

Case Status

CASE(Status, “New”, IMAGE(“/resource/1523798147000/GraphicsPackNew/silk/16/silk/star.png”, “New”),

“Working”, IMAGE(“/resource/1523798147000/GraphicsPackNew/silk/16/silk/comments.png”, “Working”),

“Escalated”, IMAGE(“/resource/1523798147000/GraphicsPackNew/silk/16/silk/flag_red.png”, “Escalated”),

IMAGE(“/resource/1523798147000/GraphicsPackNew/silk/16/silk/heart.png”, “Closed”))

18 thoughts on “Use Images in Salesforce Formula Fields to Spice up Your Org

  1. Avatar

    Thanks for the useful information. And is it possible to add your images or can I use only images from the Graphics Pack?

  2. Avatar

    Nicolas COMMEAUX


    Thanks for these examples !

    Formulas are also a good way to display “Progress bars” thanks to 3 “One pixel images” and a simple formula :
    IF (Amount_Realized__c > Amount_Objective__c, IMAGE(‘/resource/green’, ‘Test’, 15, 100),
    IMAGE(‘/resource/blue’, ‘Test’, 15, Amount_Realized__c/Amount_Objective__c * 100) &
    IMAGE(‘/resource/grey’, ‘Test’, 15, (100 – Amount_Realized__c / Amount_Objective__c * 100 )))

  3. Avatar

    i’ve just test this package and your example are not working.
    to have image into your formula field you have to launch Document ID of your image and URL of your image

    for Example to have medal on your leads you have to create formula field like this:

    CASE( Rating ,
    “Hot”, IMAGE(“/servlet/servlet.FileDownload?file=0150Y000001kngV”,”Hot”,16,16),
    “Warm”, IMAGE(“/servlet/servlet.FileDownload?file=0150Y000001kngb”,”Warm”,16,16),
    “Cold”, IMAGE(“/servlet/servlet.FileDownload?file=0150Y000001kngP”,”Cold”,16,16),

    1. Avatar

      @Arnaud : Your solution is also working but you really should use Static Ressources instead of Documents to avoid IDs directly in your formula that is hard to maintain when you deploy from an Org to another.

  4. Avatar

    Hello Ben,

    I am trying your solution but I only seem to get
    So I see the code instead of the image itself.

    I tried Html in formulas earlier without an issue but it seems that since the summer 18 this is not working?
    I use this in a custom Activity field.

    Any advise on this?

    Kind regards,

  5. Avatar

    Hi Ben and thanks for this.
    I’m trying to show an image in the SF1 default page view using formula field + image etc. with no luck.
    Did you mange to do this somewhere successfully?

    Many thanks

  6. Avatar

    Hi Ben,

    That is great, I did in the past for status and other simple indicators, and I was actually thinking about implementing this to fulfill some visibility need for my users.

    We need to find a way to flag to users that the Case has an attachment, I wanted to do this on the ListView. So when they are looking for their queues, they know right away instead of going to the Related tab and scrolling down to the files related list.

    Have you come across with any Clip image, you the one that indicates attachments? Have you any suggestions on how to achieve this solution?

  7. Avatar

    This is great for fields that aren’t used in communities. I don’t think this is possible for a community as it is not hosted on your salesforce instance. Be sure to keep this in mind when setting up requirements!

  8. Avatar

    Edward Santandrea


    WHERE are these images stored in Salesforce, meaning Documents, Files, etc? I am in an existing org, with an existing formula field that does reference a “/resource/” based image link (but it does not reference “GraphicsPackNew”, and its not in Installed Packages), so these are images uploaded to Salesforce separately to support this formula field, but I am having a heck of a time finding them (as a file, the formula displays the images properly). I’ve looked in Files > Asset Library as well as Documents. Any suggestions?

    1. Avatar

      You have to install the Graphics Pack first after that all images are stored in Graphics Pack tab

  9. Avatar

    Now that LEX using FIles, I can’t seem to get this work with uploaded images, whereas I was able to do this without issue when using Documents. So frustrated!

Leave a Reply