User Story
Create a formula which adds the following images based on the value of rating.
Cold: https://cdn1.iconfinder.com/data/icons/line-christmas-icons/75/_snowflake-256.png
Warm: https://cdn3.iconfinder.com/data/icons/covid-19-coronavirus-protection-or-prevention-fill/64/HotCovid-19-256.png
Hot: https://cdn2.iconfinder.com/data/icons/flat-icons-19/512/Fire.png
Code
CASE(Rating ,
"Cold", IMAGE("https://cdn1.iconfinder.com/data/icons/line-christmas-icons/75/_snowflake-256.png", "light"),
"Warm", IMAGE("https://cdn3.iconfinder.com/data/icons/covid-19-coronavirus-protection-or-prevention-fill/64/HotCovid-19-256.png", "light"),
"Hot", IMAGE("https://cdn2.iconfinder.com/data/icons/flat-icons-19/512/Fire.png", "light"),
"")
With width and height:
CASE(Rating ,
"Cold", IMAGE("https://cdn1.iconfinder.com/data/icons/line-christmas-icons/75/_snowflake-256.png" , "Photo Not Found" , 25, 25),
"Warm", IMAGE("https://cdn3.iconfinder.com/data/icons/covid-19-coronavirus-protection-or-prevention-fill/64/HotCovid-19-256.png", "Photo Not Found" , 25, 25),
"Hot", IMAGE("https://cdn2.iconfinder.com/data/icons/flat-icons-19/512/Fire.png", "Photo Not Found" , 25, 25),
"")
Explanation
This formula uses the Salesforce formula function "CASE" which is used to check the value of a "Rating" field and depending on the value it returns an image path.
The first parameter of the CASE function is the value that you want to check, in this case "Rating". The following parameters are the different possible values for the "Rating" field and the corresponding return values.
It checks the value of "Rating" field and depending on the value it returns the corresponding image path:
- if the value is "Cold" then it returns an image path for a snowflake image
- if the value is "Warm" then it returns an image path for a hot icon image
- if the value is "Hot" then it returns an image path for a fire image
- If the value of "Rating" is not Cold, Warm, or Hot, the function will return a blank value.
So, this formula can be used to display an image based on the value of the "Rating" field in Salesforce.