How to Add Images into a Salesforce Formula Field: A Step-by-Step Guide

Adding images to Salesforce Formula Field can significantly enhance user experience by providing visual cues, branding, or graphical representations of data. This guide walks you through the process of incorporating images into formula fields, complete with practical examples and tips.

Use Case: For service reps managing Case records, a priority flag with distinct colors (Red for High, Orange for Medium, Green for Low) helps quickly identify case priorities. This visual approach makes it easier to recognize priorities at a glance compared to text alone.

Uploading Images as Static Resources in Salesforce

Before you can integrate images into Salesforce Formula Field, you need to upload them to Salesforce as static resources.

  1. Go to Setup in Salesforce.
  2. In the Quick Find box, type Static Resources and select it.

Upload Your Images

  1. Click New.
  2. Enter a Name for your static resource (e.g., cse_low_priority_flag).
  3. Upload your image files (e.g., cse_low_priority_flag.png, cse_medium_priority_flag.png, cse_high_priority_flag.png).
  4. Click Save.

AD 4nXfHhnw9J7MqbHCadOzLd50opKfWjxdDBzq7t0dQPB0O6BomYTgv9I58BH64KZ2OUCaK3ltASQZYKQa6CebfwB1xesCxMLaEky 2eqtj2te21nWVQCqFKwQfBRJTML1 qRY1qqysKAJlGHXVtVnYSmWldD5Y?key=UiIWM7K9uVBIw5mj

Create Salesforce Formula Field for Displaying Images

Once your images are uploaded, you can create formula fields that use these images based on specific criteria.

  • Go to Setup.
  • Click on the Object Manager tab.
  • Choose the Case as an object.

Create a New Formula Field

  • Go to Fields & Relationships and click New
  • Choose Formula as the data type and click Next.
  • Enter a Field Label (e.g., Priority Flag), and choose Text as the Return Type. 

Enter the Formula

  • Use the IMAGE function to include images in your formula. The IMAGE function requires four parameters

    URL of the image
    Alt Text for the image
    Width of the image
    Height of the image

Example formula for displaying images based on case priority:

CASE( Priority, 
'High', IMAGE('/resource/cse_high_priority_flag', 'High', 40, 40), 
'Medium', IMAGE('/resource/cse_medium_priority_flag', 'Medium', 40, 40), 
'Low', IMAGE('/resource/cse_low_priority_flag', 'Low', 40, 40), 
IMAGE('/resource/cse_medium_priority_flag', 'Default', 40, 40) )
Salesforce Formula Field

Save and Add to Layout

  • Click Next, set field-level security as needed, and then click Save.
  • Go to the Page Layouts section and add the formula field to the desired page layout.

Testing Your Salesforce Formula Field

Go to the Case Record page and create new records with priorities set to ‘Low,’ ‘Medium,’ and ‘High.’ Check whether the priority flag field displays images that are generated dynamically for each priority level.

Salesforce Formula Field

Awesome! We’ve successfully fulfilled the requirement by adding the images into the Salesforce Formula Field 

Tips for Using Images in Salesforce Formula Fields

  • File Sizes: Keep image file sizes small to ensure quick loading times and optimal performance.
  • Dimensions: Choose dimensions that fit well within your Salesforce page layouts. Adjust the width and height in the IMAGE function to suit your design needs.
  • Alt Text: Provide meaningful alt text for accessibility and better user experience.
  • Static Resource Naming: Use clear and consistent naming conventions for static resources to avoid confusion.

Conclusion

Adding images to Salesforce Formula Field is a powerful way to enhance the visual appeal and functionality of your Salesforce records. By uploading images as static resources and using the IMAGE function in your formula fields, you can create dynamic, visually engaging record pages that provide clear, actionable insights.

If you find this article useful, please share it with your Salesforce colleagues/friends. Thank you for reading. Please do follow FlutterAnt for more interesting insights .

Happy Salesforce … 🙂

Loading

Leave a Comment