Building an Account Revenue indicator using a formula field and custom images

Increasingly on the Web, we find websites that use images of gold or silver stars to provide reviews and to rank the quality or usefulness of various products and services.

It has become universally accepted that one or no star equates to something very poor and a rating of five stars is seen to be excellent. By building an incremental number of images, we can create an associated image list of, say 1 to 5, that conveys a rating and ranking factor.

For this recipe, we are using a dollar image that will be repeated depending on the value of the Account Revenue amount.

Note

The dollar image we are using is a custom image and is not provided by the Salesforce CRM application.

Using the value entered in the standard Account Revenue field we will create a custom formula field to build a set of images, from one to five, whenever the Account Revenue amount meets a certain threshold criteria.

The thresholds that will formulate are:

  • Greater than (or equal to) $100,000 = one dollar image
  • Greater than (or equal to) $500,000 = two dollar images
  • Greater than (or equal to) $1 million = three dollar images
  • Greater than (or equal to) $2 million = four dollar images
  • Greater than (or equal to) $5 million = five dollar images

Amounts less than $100,000 will have no images displayed.

Getting ready

We can use custom images that we have either created ourselves or obtained from an external source and store them in the Salesforce CRM application.

External images can be uploaded into Salesforce CRM by carrying out the following steps:

  1. Create or source a suitable image to represent a dollar symbol.

    Note

    The image we have used here is a 16-by-16 pixel icon called money_dollar.png available from famfamfam.com, shown as follows:

    Getting ready

    FamFamFam have provided various images from their "Silk Icons library" available under the Creative Commons Attribution 2.5 License at http://www.famfamfam.com/lab/icons/silk/.

  2. Navigate to the Static Resources setup page by going to Your Name | Setup | Develop | Static Resources.
  3. Click on New.
  4. Enter the name of the Static Resource in the Name field. For this recipe type the text money_dollar.
  5. In the File uploader control, click on the Browse... button to select the image to upload from your computer. In this recipe choose the image identified in step 1.

    Note

    Ignore the Cache Control picklist selection and leave it as default Private (Cache Control is only relevant to static resources used in Force.com sites).

    The Static Resources setup screen appears, shown as follows:

    Getting ready
  6. Click on Save.

Note

Static resources allow us to upload images that we can reference within Salesforce CRM, such as from formula fields, Visualforce pages, and so on. This reference is a Web URL and is formed as /resource/[UNIQUE ID]/money_dollar where the [UNIQUE ID] is a unique ID which is generated for every static resource and is unique throughout every Salesforce CRM system.

Now, to find the ID for the static resource uploaded above, carry out the following steps:

  1. Click on View File, as shown in the following screenshot:
    Getting ready
  2. Note the Web URL that is displayed in the browser address bar; this is the ID for the static resource, as shown in the following screenshot:
    Getting ready

    Note

    The URL that is generated is /resource/1360798680000/money_dollar.

    You will now need to make a note of the URL that is shown in your Salesforce organization. This URL is specified for the reference to the image in a custom formula field that is used in this recipe using the steps in the following section.

How to do it...

Now let's create the custom field that will reference the dollar image that was uploaded above:

  1. Navigate to the Account customization setup page by going to Your Name | Setup | Customize | Accounts | Fields.
  2. Click on New.

    Note

    We will be presented with the Step 1. Choose the field type page.

  3. Select the Formula option, as shown in the following screenshot:
    How to do it...
  4. Click on Next.

    Note

    We will be presented with the Step 2. Choose output type page.

  5. Enter Account Revenue Graphic in the Field Label textbox.
  6. Click on Field Name. When clicking out of the Field Label textbox Field Name is automatically filled with the value Account_Revenue_Graphic.
  7. Set the Formula Return Type as Text.
  8. Click on Next.

    Note

    We will be presented with the Step 3. Enter formula page.

  9. Paste the following code in the formula edit box (as shown in the image further down):

    Note

    Remember to replace the URL shown with the URL from your Salesforce organization.

    /********************************************************  
    Begin the check for Annual Revenue value and set the following:
    Greater than (or equal to) 100,000 = One Dollar image 
    Greater than (or equal to) 500,000 = Two Dollar image 
    Greater than (or equal to) 1,000,000 = Three Dollar image
    Greater than (or equal to) 2,000,000 = Four Dollar image 
    Greater than (or equal to) 5,000,000 = Five Dollar image 
    *********************************************************/
    IF( AnnualRevenue > 99999, IMAGE("/resource/1360798680000/money_dollar", "$", 16, 16),"")
    &
    IF( AnnualRevenue > 499999, IMAGE("/resource/1360798680000/money_dollar", "$", 16, 16),"")
    &
    IF( AnnualRevenue > 999999, IMAGE("/resource/1360798680000/money_dollar", "$", 16, 16),"")
    &
    IF( AnnualRevenue > 1999999, IMAGE("/resource/1360798680000/money_dollar", "$", 16, 16),"")
    &
    IF( AnnualRevenue > 4999999, IMAGE("/resource/1360798680000/money_dollar", "$", 16, 16),"")
  10. Optionally enter the following in the Description field:
    Greater than (or equal to) 100,000 = One Dollar image
    Greater than (or equal to) 500,000 = Two Dollar image
    Greater than (or equal to) 1,000,000 = Three Dollar image
    Greater than (or equal to) 2,000,000 = Four Dollar image
    Greater than (or equal to) 5,000,000 = Five Dollar image
  11. Optionally enter the following in the Help Text field:
    1 Dollar image = 100,000 or more
    2 Dollar images = 500,000 or more
    3 Dollar images = 1,000,000 or more
    4 Dollar images = 2,000,000 or more
    5 Dollar images = 5,000,000 or more
  12. In the Blank Field Handling section, select the Treat blank fields as blanks option, as shown in the following screenshot:
    How to do it...
  13. Click on Next.

    Note

    We will be presented with the Step 4. Establish field-level security page.

  14. Select the profiles to which you want to grant read access to this field via field-level security. The field will be hidden from all profiles if you do not add it to field-level security.
  15. Click on Next.

    Note

    We will be presented with the Step 5. Add to page layouts page.

  16. Select the page layouts that should include this field. The field will be added as the last field in the first 2-column section of these page layouts. The field will not appear on any pages if you do not select a layout.
  17. Click on Save.

How it works...

The formula field graphic is dynamically generated based on the annual revenue value and the rendered image appears on the Account Detail page.

You can see what this looks like when the Annual Revenue is set to $1,000,000 in the following screenshot:

How it works...

You can see what this looks like when the Annual Revenue is set to $6,000,000 in the following screenshot:

How it works...
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.226.172.200