Advanced Image formula fields

Standard

Earlier I had a tutorial on how to create an image formula field in salesforce.com. In this tutorial I am going to take this a little farther. I will show how to have multiple images in one formula field.

An example of having multiple images in one salesforce.com formula field could be something like showing multiple images of money for amounts of all Opportunities on an Account.

  • First thing you want to do is create a Roll-up Summary field on the Account object.
  • Name the field “2013 Sales”.
  • Then choose Opportunities as the Summarized Field.
    • Sum
    • Field to Aggregate = Amount
    • Only records meeting certain criteria should be included in the calculation
    • You will want three criteria
      • (Close Date GREATER OR EQUAL 1/1/2013)
      • ¬†(Close Date LESS OR EQUAL 12/31/2013)
      • (Won EQUAL True)

The above will give you a total amount of all 2013 sales for each Account.

With the next steps we will build the field that will display the images. We will show 1 image of money for account that have over $0 in sales but less than $10,001. Show two images for accounts with less than $25,001 in sales. Three images for accounts that have less than $50,001 in sales. 4 images for accounts that have less than $100,001 in sales. And 5 images for all accounts that have more than $100,000 in sales.

  • Create a new formula field
  • Name the field “Show me the money”
  • Choose Text as the formula field type
  • For the formula paste in the following (I will go into detail afterwards)
    • IF ( 2013_Sales__c > 0, IMAGE(“/img/icon/cash24.png”, “money”, 18, 18), NULL)+ ” ” +

      IF ( 2013_Sales__c > 10000, IMAGE(“/img/icon/cash24.png”, “money”, 18, 18), NULL)+ ” ” +

      IF ( 2013_Sales__c > 25000, IMAGE(“/img/icon/cash24.png”, “money”, 18, 18), NULL)

      + ” ” +

      IF ( 2013_Sales__c > 50000, IMAGE(“/img/icon/cash24.png”, “money”, 18, 18), NULL)

      + ” ” +

      IF ( 2013_Sales__c > 100000, IMAGE(“/img/icon/cash24.png”, “money”, 18, 18), NULL)

    • Choose¬†Treat blank fields as zeroes.
    • Go through the rest of the steps and save.

So what you are doing is simply adding more images to the formula field each time the IF statement is true (and when false it is NULL, thus adding nothing). We are using the salesforce.com cash icon (read my first post on image formulas to find out how you can use these images). It is really that simple. The + sign just keeps adding additional images. You don’t need to use the same image on each if statement. You can do whatever you want.

The biggest key to this is the size of the image. The , 18, 18 at the end of each image is the width and height. You MUST put this in or the formula will give an error when two or more images will be displayed. Again…this is a MUST or the formula won’t work as intended.

I add a blank space between each image using + ” ” + . I just like a little space between each image. This is a preference thing. You can simply use a + sign between each IF statement, if you want.

Go play around with this and have fun. Spruce up your salesforce.com pages with some images!

2 thoughts on “Advanced Image formula fields

  1. Karthi

    Can I upload a Image which has been saved in my Local Computer(Personal Folder).?How to pull the image from Local folder to Sales force Object field, If possible can you provide me the Code.

  2. Kalyani loganathan

    Hi Bill
    My formula is throwing error

    IF(!Pipeline__c, IMAGE(“servlet/servlet.FileDownload?file=015i0000004Epk5”, “Do Not Forget to Enter the following before Submitting for Approval”),
    IF(AND(!Pipeline__c,ISPICKVAL(StageName,”A”)), IMAGE(“servlet/servlet.FileDownload?file=015i0000004Epk5″,”*** This opportunity stage can be submitted for approval***”),null ) )

Leave a Reply

Your email address will not be published. Required fields are marked *