08 Feb Displaying image in a Formula Field
We all have used formula fields for calculations, values from related objects and what not!
But have you ever used it to display an Image?
If Not, then continue reading to know how to display an image using a formula field.
Formula field evaluates the logic and displays the result on to the screen. Images from the static resource, URLs are displayed by Using IMAGE Function.
Example 1: Flags
Suppose you have a Picklist Field (Api Name = Priority__c) with values as High,Medium and Low . You can display different colour flags for different picklist value using a formula field.
Create a formula field with Text as return type value and copy paste the below code in the formula editor: Change the highlighted text with your picklist field’s api name.
CASE( My_Priority__c ,
“High”,”https://c.ap2.visual.force.com/resource/1469447086000/HighFlag”, “null”), “Image”)
Example 2: Traffic Lights
Traffic Lights can be displayed using the formula field. Let us assume that you have a picklist field, called as, Status with values Red,Green and Yellow. Create another formula field to represent the Status Pictorially. Use the below mentioned formula. Change the highlighted text with your picklist field API name.
IMAGE( CASE ( Traffic_Status__c,
Example 3: Star Ratings
Formula fields can even be used to display Rating Stars. Assume that you have a picklist field called as Rating with the picklist values ranging from 1-5. Create a formula field and enter the code as mentioned below in the formula editor.Change the highlighted text with your picklist field API name.
IMAGE( CASE ( App_Rating__c,
Example 4: Image from a URL
Images from the URL field can also be displayed using formula fields. Lets say the API name of url field is Image_url__c , then use the below mentioned code to create a formula field which would display the image. Change the highlighted text with your URL field API name.
IMAGE( Image_Url_Feild__c, “https://c.ap2.visual.force.com/resource/1469452611000/newimage”,200, 200)
In this way we display an image using a formula field.