Saturday 29 December 2012

Display an image as a custom field on Salesforce

18:05

There are many times when we need to display an image as a custom field like when a status of a contact is changed to pending or accepted. 
                    
Though this is possible natively on force.com it is not so direct. Here’s an example which will illustrate how to display an image on/as a custom field on salesforce.com


You need to be an administrator or should have the permissions to modify Objects.

Following are the Steps:


1) Upload the Image to Salesforce

  •     Navigate to the documents tab

  • Fill in the details of your file, make it externally available and click save 
  • Once the image is saved, keep a note of its record id, which can be found on the URL(ex: 015U0000000HxC9)

2) Now we need to add a custom field to the object where we need to display the image, here I am adding the field to a custom object

·                  Navigate to Setupà Create à Objects à (Custom Object) à Add new Custom field
·                   On Step 1 Select the field type as “formula” and click next
·                   On Step 2 Select the Field Return type as “Text”
·                   On step 3 Select the Advanced Formula
Specify the condition on which the image is to be displayed. E.g. I want to display this image when my status field is set to “accepted”,

IF(
ISPICKVAL(Status__c,'Accepted'),
IMAGE('/servlet/servlet.FileDownload?file=015U0000000HxC9',""),
)

Replace the Record ID of your file on the highlighted code.
·         On Step 4 & 5 select the settings you wish and click save.

Now you can see the image on the page layout according to your specified formula.

Hope this helped you. Please leave a comment if you need any help regarding this post or any other force.com related issues.

More info on

Image Function: http://bit.ly/rbgVtD
Documents Tab: http://bit.ly/p4CdFs