Print this page

Use images in Formula Fields

Knowledge Article Number 000007604
Displaying images that are dependent on the value of another field in an Object is a very useful feature; it can be used to highlight the status of an Opportunity, Lead, Case Age, the dollar amount in a Contract, etc. Learn how to create a Formula Field that displays an image below. 

Steps to create a Formula Field that displays an image

1. Create a public folder to hold your image files
      1. Click the Documents tab.
      2. Click Create New Folder.
      3. Type the folder name (e.g., "Public Images").
      4. Give users "Read-Only" access to the folder and make it accessible to all users.

2. Upload your image file to your Documents storage area

      1. Click the Documents tab.
      2. Click New.
      3. Enter the document name to be displayed on the browser.
      4. From the Folder dropdown list, select the folder you created in step #1.
      5. Click on Browse to look for and select the file to upload.
      6. Click Save.

3. Repeat step # 2 to upload all your image files

4. Create a new Formula Field of type text (it must be of type text or it won't work)

      1. Go to Setup | Customize | <Object> you are going to customize (Accounts, Case, etc.).
      2. Click on Fields.
      3. Click on New" in the "Custom Fields" section.
      4. Select Formula.
      5. Click Next.
      6. Type your custom field name, and then select type Text.
      7. Click "Next."
      8. In the "Enter Formula" screen, click on "Advanced Formula."

5. Obtain the URL to the file(s) you uploaded

      1. Click the Documents tab.
      2. From the Folder dropdown list, select the folder you created in step #1.
      3. Click Go.
      4. Click on the "View" link next to the name of the file you are going to use.
         -A new browser window/tab will open.
      5. Go to the address bar, highlight and copy the URL.

6. Go back to editing your formula field. Use the IMAGE function to fetch the image from your folder

      1. In the text area, enter your formula using IMAGE to retrieve the image file you uploaded in step # 2. 
      2. Paste the image document URL into the 'image_url' part of the IMAGE function.

7. Repeat steps # 5 & 6 until you have all the URLs to all your image files in your Formula Field

8. Grant the appropriate Field-Level Security to your Formula Field

9. Include the Formula Field in all the relevant Page Layouts


Example #1:
    IF( Amount > 100, IMAGE("/servlet/servlet.FileDownload?file=01570000000Q6El", "Green"),
       IF ( Amount > 50, IMAGE("/servlet/servlet.FileDownload?file=01570000000Q6Ef", "Yellow"),
          IMAGE("/servlet/servlet.FileDownload?file=01570000000Q6Ep", "Red")))

This example displays a GIF image of a green square if the amount of an opportunity is greater than 100, a yellow square if it's under 51 and 99, and a red square if it's less or equal to 50.

IMPORTANT: Although percentage fields appear to have whole number values they are in fact decimals. For example, 50% in the opportunity probability field is actually 0.5 rather than the assumed 50. So the formula for a percent field should look like this (using probability field as example):

IF ( Probability > 0.50, IMAGE("/servlet/servlet.FileDownload?file=01570000000Q6Ef", "Yellow")


Example #2: IMAGE("", "Flower", 300, 300)

This example displays the JPG image of a flower regardless of the value in any field.

Good to Know: 

  • The URLs must be enclosed in double-quotes.
  • Strip the domain name "" off the URL you paste into the IMAGE function, since it's not required.
  • It's best to point to URLs in the document storage area of your org to prevent "link rot."
  • Check Help & Training for more information on the options and syntax of the IMAGE function.

promote demote