As I’ve blogged before in my series about configuring Salesforce for usability, Image Formula Fields can be just the thing to make something pop on a page layout and let a user know at a glance if everything is looking good or if there is work to be done. Some of the images I use often with our clients here in Texas are the Flag, Star and Stoplight icons. They are great way to convey visually the status, aging, value, rating, or health of a record.
Though Salesforce provides some examples to get you started with Image Formula Fields, I thought a handful of real-life examples would be a good way to see how they are used as well as get used to the formula syntax.
Example Flag 1
IF( Approval_Status__c =”Rejected”,
IMAGE ( “/img/samples/flag_red.gif”,”Red”),
IF( Expiration_Date_of_Deviation__c > TODAY(),
IMAGE(“/img/samples/flag_green.gif”,”Green”),
IMAGE ( “/img/samples/flag_red.gif”,”Red”)))
Example Flag 2
IF (ispickval( Category__c ,””),””,
IF (Face_to_Face_Status__c =”Neglected”,
IMAGE( “/img/samples/flag_red.gif”,”Negleted”)
IMAGE( “/img/samples/flag_green.gif”,”Current”)))
Example Flag 3
IF(Case_Age_Days__c >15,
IMAGE( “/img/samples/flag_red.gif”,”Greater Than 15 Days”),
IF(Case_Age_Days__c >7,
IMAGE(“/img/samples/flag_yellow.gif”,”8-15 Days”),
IMAGE( “/img/samples/flag_green.gif”,”Less than 7 Days”) ))
Example Flag 4
IF(AND ( Years_Employed__c >= 20, Net_Worth__c >350000, X401K_Savings__c >=50000,
OR(Years_Until_Retirement__c <=5, Retirement_Rating_Score__c >=75)),
IMAGE(“/img/samples/flag_green.gif”, “Yes”),
IF(and(Years_Employed__c >= 20, Years_Until_Retirement__c >5, (Taxable_Accounts__c + Outside_IRAs__c + Roth_IRAs__c ) >= 250000),
IMAGE(“/img/samples/flag_green.gif”, “Yes”),
IMAGE(“/img/samples/flag_red.gif”, “No”)))
Example Stars 1
IMAGE(CASE( Hidden_Star_Score__c ,
1, “/img/samples/stars_100.gif”,
2, “/img/samples/stars_200.gif”,
3, “/img/samples/stars_300.gif”,
4, “/img/samples/stars_400.gif”,
5, “/img/samples/stars_500.gif”,
“/img/samples/stars_000.gif”), “rating”)
Example Stars 2
IF ( Net_Worth_Calc_Star_Rating__c<=350000, IMAGE(“/img/samples/stars_100.gif”,”1 Star”),
IF ( Net_Worth_Calc_Star_Rating__c <=500000, IMAGE(“/img/samples/stars_200.gif”,”2 Star”),
IF ( Net_Worth_Calc_Star_Rating__c <=1000000, IMAGE(“/img/samples/stars_300.gif”,”3 Star”),
IF ( Net_Worth_Calc_Star_Rating__c <=2000000, IMAGE(“/img/samples/stars_400.gif”,”4 Star”),
IMAGE(“/img/samples/stars_500.gif”,”5 Star”)))))
Example Stoplight 1
IF( Retirement_Rating_Score__c > 75,
IMAGE ( “/img/samples/light_green.gif”, “75+”),
IF( Retirement_Rating_Score__c > 65,
IMAGE ( “/img/samples/light_yellow.gif”, “65-75”),
IMAGE ( “/img/samples/light_red.gif”, “<65”)))
Example Stoplight 2
IF(not(ispickval(Electro_Fishing_Unknown_Date_Reason__c,”” )),
IMAGE(“/img/samples/light_red.gif”,”Red”),
IF(ispickval( Electro_Fishing_Surveys__c , “N/A”),
IMAGE(“/img/samples/light_green.gif”,”Green”),
IF(AND(ispickval( Electro_Fishing_Surveys__c , “1 Month”), Days_Since_Last_Electro_Fishing_Surveys__c <30),
IMAGE(“/img/samples/light_green.gif”,”Green”),
IF(AND(ispickval( Electro_Fishing_Surveys__c , “3 Months”), Days_Since_Last_Electro_Fishing_Surveys__c <90),
IMAGE(“/img/samples/light_green.gif”,”Green”),
IF(AND(ispickval( Electro_Fishing_Surveys__c , “6 Months”), Days_Since_Last_Electro_Fishing_Surveys__c <180),
IMAGE(“/img/samples/light_green.gif”,”Green”),
IF(AND(ispickval( Electro_Fishing_Surveys__c , “Annually”), Days_Since_Last_Electro_Fishing_Surveys__c <365),
IMAGE(“/img/samples/light_green.gif”,”Green”),
IF(AND(ispickval( Electro_Fishing_Surveys__c , “Every 2 Years”), Days_Since_Last_Electro_Fishing_Surveys__c <735),
IMAGE(“/img/samples/light_green.gif”,”Green”),
IMAGE(“/img/samples/light_red.gif”,”Red”))))))))
Working with Custom Graphics
OK, let’s take this train of thought one level higher. What if you want to use a formula to display a custom image? To do that, first upload the image into the Documents folder. Once you have the image uploaded and it displays on the Document record correctly (i.e. it’s visible on the screen), right click the image and try to grab the URL. It should look something like this if you paste the URL into the custom field formula editor:
https://na4.salesforce.com/servlet/servlet.ImageServer?id=01560000000jSOQ&oid=00D60000000Ixyz
If so, you can write a formula that looks something like the example below:
IF(ISPICKVAL(Operating_Company__c ,”Option 1″),
IMAGE ( “/servlet/servlet.ImageServer?id=015600000013oUW&oid=00D60000000Ixyz”,”Option 1″),
IMAGE ( “/servlet/servlet.ImageServer?id=01560000000jSOQ&oid=00D60000000Ixyz”,”Option 2″))