Display an image as a custom field on Salesforce

Dream. Dare. Do – that is Suyati’s work principle in a nutshell.

  • Author:
  • Shiv

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.

Steps:

We need to upload the image to be used

  1. Navigate to All tabs –> Documents tab–> click “new” button
  2. Fill in the details of your file, make it externally available and click save
  3. Once the image is saved , keep a note of its record id , which can be found on the URL (ex: 015U0000000HxC9)

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

  1. Navigate to Setup–> Create–>Objects–> (custom Object) –> Add new custom field
  2. On Step 1 Select the field type as “formula” and click next
  3. On Step 2 Select the Field Return type as “Text”
  4. On Step 3 Select the Advanced Formula,

Specify the condition on which image is to be displayed. E.g. I want to display this image when my status field is set to “accepted”, therefore I write an IF condition

IF(

ISPICKVAL(Status__c,’Accepted’),

IMAGE(‘/servlet/servlet.FileDownload?file=015U0000000HxC9‘,””),

)

Replace the Record ID of your file on the highlighted code.

  1. 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.

 

 

 

 

Comments (2)
admin (8 months ago)

We can't implement this by using 'apex:selectOption' in visualforce. But we can achieve this using plugins (like http://www.marghoobsuleman.com/mywork/jcomponents/image-dropdown/samples/index.html)

Aaryan (5 years ago)

hello, Shiv I have one picklist field "status". And it has values : 1:"Not Submitted" & Image ID = "015V00000004uIq". 2:"Pending Approval" & Image ID = "015V00000004uIr". 3:"Approved" & Image ID = "015V00000004uIo". 4:"Rejected" & Image ID = "015V00000004uIt". Now how can i use them with using CASE function. ????? Thanks in advance.

Get Our Newsletter

CMSCRMOpensourceEcommerce