Use Images in Salesforce Formula Fields to Spice up Your Org

Share this article...

Salesforce image formula fields display image icons to Salesforce users according to the field value/s a record has, instead of calculating a number, or outputting a string of text. Simply speaking, the formula statements will ask: “if this equals [some value], show [image A], if not, show [image B]”. This is a basic, two-line example, and you may already know that Salesforce formulas can be several lines long, to switch between different images in formula fields.

Image formulas in Salesforce are a great addition to your org to help users to digest information quickly on records or list views, and bring their attention to what’s important. Salesforce image fields can be tricky to apply on your first few attempts, which is why we’ve included Salesforce image formula examples to get you started.

How Do I Use a Graphics Pack in Salesforce?

Let’s begin by downloading the Salesforce Graphics Pack from the AppExchange. Thanks to our friends over at Salesforce Labs, we instantly have a whole host of icons to play around with.

Access your Salesforce image library by heading to the App Launcher (waffle icon), and searching “Lightning Graphics Pack”:

This launches an icon library with several tabs (‘Farm Fresh’, ‘Icon Shock’, ‘Tango Desktop Project’, etc. are icon developers. The icons are not categorized in any other way). Take a look around, there are hundreds to choose from!

How Do I Apply an Image Formula in Salesforce?

In this tutorial, we will add an “Account Health” formula field, based on the standard “Rating” picklist field.

What is a Formula in Salesforce? If you’re new to formulas check out this Trailhead module.

Step 1: Create a custom formula field

In Salesforce Setup, head to the Object Manager → Account → Fields & Relationships → ‘New’ (button).

  • Choose the field type: Formula
  • Field label: Account Health
  • Formula Return Type: Text*

*note there is no option for ‘image’ return type, which often trips people up.

Step 2: Write the Salesforce image formula

Here’s the whole formula and what each part of the formula means:

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"))
  • CASE: a Salesforce formula function where you have multiple statements relating to picklist field values. In this example, the formula is asking “if the rating is “Hot” then show [image A], if the rating is “Warm” then show [image B], if the rating is “Cold” then show [image C]”.
  • IMAGE: indicates you are about to reference an image file.
  • “/resource/… : the image URL. Clicking on an icon in the Graphics Pack will open the file in a new tab. That tab contains the URL, eg. [your domain]/resource/1630492553000/GraphicsPackNew/fatcow/farmfresh/16/film.png
  • “Hot”: you see the picklist value repeated after the image URL – that’s known as the Alt text. That will appear to the user in case the image doesn’t load properly, so is a good fallback option.

Before you write your formula, pick out the graphics you want to use, and list out the image file URLs and picklist values. Copying and pasting from your notes will make building the formula in the formula editor clearer.

Click “Check Syntax”, which will check your formula is written correctly and references fields that exist.

Step 3: Test the logic

Test all scenarios by selecting each picklist value at a time, clicking save, and checking the icon you expect appears on the record.

Note: the icon won’t change until you save the record.

Step 4: Add the icons where users need it

Add the image formula field to:

  • Record pages
  • The highlights bar on record pages
  • List views
A list view with an image formula field added.

Salesforce Image Formula Examples

Account Health Rating

The example in the tutorial was based on the standard “Rating” field, however, your organization may have another definition of what a ‘healthy’ account looks like. Could it be the last activity date? If they are approaching the end of a contract, and there’s no renewal opportunity being worked on?

Case Status Image

Quickly show which Cases need attention with a simple image field based on 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"))

Lead Score

If your users have a high volume of leads to work through, help them prioritize who’s worth talking to by highlighting sales-ready prospects, leads from target accounts, or that fit your ideal customer profile.

The most simple version is to base the formula on the standard “rating” field.

If you use a marketing automation platform, it almost certainly has lead scoring functionality (usually a number) that can be synced across to Salesforce. This tutorial shows you how to create a Salesforce star rating formula fields for Pardot Prospect score:

Mailability Flags

Another of my favorites to add to Salesforce orgs is flags to make communication preferences highly visible. Not only does this stop users contacting people who have opted out, it also helps sales and marketing teams work together (this is because marketing emails are treated differently to one-to-one contact).

Display a coloured flag on the Lead or Contact record in Salesforce according to the channels you want to cover (email, phone SMS):

In this example, the colour flags apply as follows:

  • Green = If not opted out of any
  • Orange = IF Opted out of Email OR Phone OR SMS
  • Red = If not opted out of all (Email AND Phone AND SMS)
IF

(HasOptedOutOfEmail = TRUE && DoNotCall = TRUE && SMS_Opt_Out__c = TRUE,

IMAGE("/img/samples/flag_red.gif", "Red Flag"),

IF

(HasOptedOutOfEmail = TRUE || DoNotCall = TRUE || SMS_Opt_Out__c = TRUE,

IMAGE("/img/samples/flag_yellow.gif","Yellow Flag"),

IMAGE("/img/samples/flag_green.gif","Green Flag")))

Read this tutorial for more examples: Create Mailability Flags in Salesforce for Highly Visible Communication Preferences

Final Thought

Now that you’ve seen the power of image formulas, ask yourself the question, “Where can my users benefit the most from images?” You don’t want to use images for the sake of it, but to help users get a glimpse of the status of their data.

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

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

    1. Yes you can add your own images to Static Resources. Go into setup and search for Static Resources, and click the new button.

  2. Nicolas COMMEAUX

    Reply

    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. Hello,
    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. @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. 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,
    Mario

  5. 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. 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. 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. Edward Santandrea

    Reply

    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. You have to install the Graphics Pack first after that all images are stored in Graphics Pack tab

  9. 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!

  10. We’ve been using this functionality for Cases for several years, to save space on the UI. Combine Status, Case origin, Priority and Record Type images into one formula field. This way we don’t have to add each field separately on the Lightning Page layout quick view for agents, making for a more compact view of essential information.

  11. You can combine these formula fields to create a multi image field and then use the one field vs. 3, 4, 5. If you set this up right with the naming you can have nested sorting based on the the combo. (Status, Severity, Account Type, Channel) Summary_Icon__c = Icon1 & Icon2 & Icon3

  12. Hi everyone and thank you Ben for this article!

    I thought I would highlight that the images do not pull through when a record is mentioned in the new Microsoft Teams Salesforce app. Otherwise this works great!

    Kam

  13. Hello, I tried to download the package but I have an error message appearing. Have you ever faced this issue before ? Duplicate Name
    The name “Graphics_Pack_for_Tabs/events_png1.png” is already used on component type: Document. Please rename existing component.

  14. Just a quick clarification, can these fields be used in dashboards? I tried grouping by a formula field with both a flag image in it and text, but the dashboard group has the image resource name in it. It’s a bummer, I might need to build a separate field for reporting but just wanted to double check that I wasn’t missing something. The formula works beautifully on list views and record pages.

  15. 3. Create a formula field in opportunity called “SLA Status” as a Text field to check the related
    Account SLA Values and display an emoji () for SLA platinum Account, () Silver , for
    Bronze (), Gold () in opportunity.

    anyone help me how can I archive this step by step

  16. 3. Create a formula field in opportunity called “SLA Status” as a Text field to check the related
    Account SLA Values and display an emoji () for SLA platinum Account, () Silver , for
    Bronze (), Gold () in opportunity.

    can anyone help me how can I archive this step by step

Add Comment