+ Start a Discussion

create image field in custom object

please let know how we will cretae image field in custom object
Any help would be appreciated
Hi Srikanthpalala,

follow below steps to create a image field.

1. Create a public folder to hold your image files
      1. Click the Documents tab.
      2. Click Create New Folder.
      3. Type the folder name (e.g., "Public Images").
      4. Give users "Read-Only" access to the folder and make it accessible to all users.

2. Upload your image file to your Documents storage area

      1. Click the Documents tab.
      2. Click New.
      3. Enter the document name to be displayed on the browser.
      4. From the Folder dropdown list, select the folder you created in step #1.
      5. Click on Browse to look for and select the file to upload.
      6. Click Save.

3. Repeat step # 2 to upload all your image files

4. Create a new Formula Field of type text (it must be of type text or it won't work)

      1. Go to Setup | Customize | <Object> you are going to customize (Accounts, Case, etc.).
      2. Click on Fields.
      3. Click on New" in the "Custom Fields" section.
      4. Select Formula.
      5. Click Next.
      6. Type your custom field name, and then select type Text.
      7. Click "Next."
      8. In the "Enter Formula" screen, click on "Advanced Formula."

5. Obtain the URL to the file(s) you uploaded

      1. Click the Documents tab.
      2. From the Folder dropdown list, select the folder you created in step #1.
      3. Click Go.
      4. Click on the "View" link next to the name of the file you are going to use.
         -A new browser window/tab will open.
      5. Go to the address bar, highlight and copy the URL.

6. Go back to editing your formula field. Use the IMAGE function to fetch the image from your folder

      1. In the text area, enter your formula using IMAGE to retrieve the image file you uploaded in step # 2. 
      2. Paste the image document URL into the 'image_url' part of the IMAGE function.

7. Repeat steps # 5 & 6 until you have all the URLs to all your image files in your Formula Field

8. Grant the appropriate Field-Level Security to your Formula Field

9. Include the Formula Field in all the relevant Page Layouts
Example #1:
    IF( Amount > 100, IMAGE("/servlet/servlet.FileDownload?file=01570000000Q6El", "Green"),
       IF ( Amount > 50, IMAGE("/servlet/servlet.FileDownload?file=01570000000Q6Ef", "Yellow"),
          IMAGE("/servlet/servlet.FileDownload?file=01570000000Q6Ep", "Red")))
This example displays a GIF image of a green square if the amount of an opportunity is greater than 100, a yellow square if it's under 51 and 99, and a red square if it's less or equal to 50.
IMPORTANT: Although percentage fields appear to have whole number values they are in fact decimals. For example, 50% in the opportunity probability field is actually 0.5 rather than the assumed 50. So the formula for a percent field should look like this (using probability field as example):
IF ( Probability > 0.50, IMAGE("/servlet/servlet.FileDownload?file=01570000000Q6Ef", "Yellow")
Example #2: IMAGE("http://images.odeo.com/1/8/4/Zencast.jpg", "Flower", 300, 300)

This example displays the JPG image of a flower regardless of the value in any field.

Please do let me know if it helps you.

Amit Chaudhary 8Amit Chaudhary 8
You can create the formula field which can pull the image .
1) https://developer.salesforce.com/docs/atlas.en-us.usefulFormulaFields.meta/usefulFormulaFields/useful_advanced_formulas_image_links.htm

Example 1:-
It is very simple .first u upload image in resourse . and then file open --> view file  then copy url.  
for example url may be https://ap1.salesforce.com/resource/1329402101000/Image1
then edit the url like this  ' /resource/Image1' 
CASE( {!Rating__c},
1, " /resource/Image1'", 'None','No Image'

Example 2:-
This formula displays a green, yellow, or red flag image to indicate case priority.
CASE( Priority, 
"Low", "/img/samples/flag_green.gif",
"Medium", "/img/samples/flag_yellow.gif",
"High", "/img/samples/flag_red.gif", 
"Priority Flag")
Example 3:-
Stars for Ratings
This formula displays a set of one to five stars to indicate a rating or score
"1", "/img/samples/stars_100.gif",
"2", "/img/samples/stars_200.gif",
"3", "/img/samples/stars_300.gif", 
"4", "/img/samples/stars_400.gif", 
"5", "/img/samples/stars_500.gif", 

PLease check below post if you are looking for VF page
1) https://developer.salesforce.com/trailhead/en/lightning_design_system/lightning-design-system5

Let us know if this will help you
  1. Create field “Status” with options: Open, In Approval, Approved, Rejected, In Development, Closed (it should not be editable by users, it will be updated by workflows as you will see)
  2. Create a field to include an image (a locker). This should be in the Sample Request Layout when the status is Approved or Rejected.
Ajay K DubediAjay K Dubedi
Hi Srikanth Pilla,
Below steps might helpful:
1. You can create a custom field of type Rich Text area that can hold images.
2. Text/URL field which holds the URL of the image from documents or static resources.
3. A formula field which can display image in desired height and width by using the value from field 1.
I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.
Ajay Dubedi
Sujay HajraSujay Hajra
Hi Ajay - when I use your option 3 above, it is creating the same image for all records in the account object where I created the custom field.