dispaly_image from file salesforce

Formula Fields to Display Images From Files/Content Documents – Salesforce Lightning/Classic

Admin Configuration

Sharing is caring!

Welcome back guys, Today in this post we are going to learn, how we can create custom formula field to display images from salesforce files or content documents (ContentVersion) object

Step 1: Obtain the File (Content Version) image file record Id.

After upload your image/Picture as file, open your file object | click on view file details

next, copy Content Document Id from URL which is started from 069xxxxxxxxxxxxxxx

now we have content document/File id, next we will fetch the contentVersion Id with this content document Id.

Check also : How To Display Lightning Component In Visualforce Page-Sample

open developer console and execute following query with your content document Id :

Note : Update your content document ID in SOQL Query

   Now, finally we got our image file (content Version) Id which has starting from 068xxxxxxxxxxxxxxx. copy it. we will use this Id in our formula field.

Step 2 : Create a new “Text” type Formula Field :

In Salesforce Classic Mode :

1. Go to Setup | Customize | <Object> — Select the Object you are going to customize (Accounts, Case, Opportunity).
2. Click Fields.
3. Under “Custom Fields,” click New.
4. Select Formula.
5. Click Next.
6. Enter your custom field name, then select Text from the “Type” picklist.
7. Click Next.
8. In the “Enter Formula” screen, click Advanced Formula and use following formula.

update your content version id in above formula and click on next and then save.

In this post for the demo purpose i have used hard code Id in formula, you can create a custom field to store file id and use that field in formula to make it dynamic.

now open any record detail page to see output :

Some Useful Resources : 

Check Also : Customize Salesforce logIn Screen In Just Few Minutes

Like our facebook page for new post updates. & Don’t forget to bookmark this site for your future reference.

if you have any suggestions or issue with it, you can post in comment box  or Developer Forums 🙂

Sharing is caring!

(Visited 992 times, 1 visits today)

One thought on “Formula Fields to Display Images From Files/Content Documents – Salesforce Lightning/Classic

  • Hello sir

    I used to learn a lot of thing from your blog.

    I have a query that if I have 10 records with some fields and a custom field that show the related image. I want to retrieve all those images in a lightning component then how can it possible??

Leave a Reply