Displaying image in a Formula Field | Techila
1236
single,single-post,postid-1236,single-format-standard,ajax_updown_fade,page_not_loaded,,qode_grid_1300,footer_responsive_adv,hide_top_bar_on_mobile_header,qode-content-sidebar-responsive,qode-theme-ver-9.4.2,bridge,wpb-js-composer js-comp-ver-4.12,vc_responsive
 

Displaying image in a Formula Field

images-in-formula-fields

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.

 IMAGE( 
CASE( My_Priority__c , 
“Low”, “https://c.ap2.visual.force.com/resource/1469447086000/LowFlag”, 
“Medium”, “https://c.ap2.visual.force.com/resource/1469447086000/MediumFlag”, 
“High”,”https://c.ap2.visual.force.com/resource/1469447086000/HighFlag”, “null”), “Image”)

1imageex.jpg

 

 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,

“Stop”,”https://c.ap2.visual.force.com/resource/1469448975000/StopSignal”,

“Wait”,”https://c.ap2.visual.force.com/resource/1469448975000/WaitSignal”,

“Go”,”https://c.ap2.visual.force.com/resource/1469448975000/GoSignal”,”null”),”image” )

2ndimageexa.jpg

 

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, 
“1”,”https://c.ap2.visual.force.com/resource/1469450129000/OneStar”, 
“2”,”https://c.ap2.visual.force.com/resource/1469450129000/TwqStar”, 
“3”,”https://c.ap2.visual.force.com/resource/1469450129000/ThreeStar”, 
“4”,”https://c.ap2.visual.force.com/resource/1469450129000/FourStar”, 
“5”,”https://c.ap2.visual.force.com/resource/1469450129000/FiveStar” 
,”null”),”image” )

3rdimageexam.jpg

 

 

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)

4thimage.jpg

 

 

In this way we display an image using a formula field.

Courtesy – http://www.worldofsalesforce.com/2016/05/displaying-images-using-salesforce.html

 

Author: techila

No Comments

Post A Comment