function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Parteek Goyal 3Parteek Goyal 3 

How to upload a picture with a record in custom object

Hi All,

How to upload a picture with a record in custom object.
Please help me
Best Answer chosen by Parteek Goyal 3
Balaji Chowdary GarapatiBalaji Chowdary Garapati
@prateeh Goyal,

  Looks like rich text area field will be a smoother option, if you are looking for mass upload of images to records directly.

Below link might help you!
https://help.salesforce.com/apex/HTViewSolution?id=000002745&language=en_US

if you are looking for the existing images which were in documents to be shown on object record, you can still rely on rich text option or as Nirmal suggested you can use formula field., to be more specific with the implementation, you might need two fields:
1) Text/url field which holds url of image from documents or static resources
2) A formula field which can display image in desired height and width by using the value from field 1.

Considering  a scenario, where real user might need to have a way to upload / alter those images, rich text area field will help more.

Thanks,
balaji

All Answers

Balaji Chowdary GarapatiBalaji Chowdary Garapati
@Parteek Goyal 3

  Are you trying to capture an image for a record in field?
*Can try using Rich Text area type field which can hold images
*Can try to attach them into documents and save that url in a field on that object.
*Can also repurpose notes and attachments for uploading images and have a visual force snippet which displays the image on standard layout.


 It really depends on the business use case you are trying to solve.

Thanks,

balaji
Nirmal ChristopherNirmal Christopher
Hi,


If you want the picture to be displayed in the record do the following

Recommended
1)Upload the photo as the attachment for the records.
2) create a formula field and update the URL of the attachment inside the formula field 
3)The Image automatically renders in the record
4)you can even set height and width of the image using the Image formula attribute inside the formula fields.

rich text fields doesnt fully support the immage the pixels and attributes in the record detail page will be a huge mess if used.

Hit best answer if it helped you.  
 
Parteek Goyal 3Parteek Goyal 3
Hi Nirmal,

Actully i want to upload picture when a record is inserted.Is it possible in salesforce?
Nirmal ChristopherNirmal Christopher
Hi Prateek Its possible programatically in dataloading tools you have to do it seperately.

In Apex parse the attachment file in to BLOB data type and map it to body of attachment inside the code.  May be something like this
 
attachment a=new attachment();
a.name='Sample';
a.body=//variable store as blob;
///////
//Insert other attachment required fields if any
/////
insert a;

If this helps please hit like and best answer it helps others.



Thanks and Regards,
Nirmal Christopher
Certfied Tech consultant, Global Tech and Resources, www.gtr.net
Balaji Chowdary GarapatiBalaji Chowdary Garapati
@prateeh Goyal,

  Looks like rich text area field will be a smoother option, if you are looking for mass upload of images to records directly.

Below link might help you!
https://help.salesforce.com/apex/HTViewSolution?id=000002745&language=en_US

if you are looking for the existing images which were in documents to be shown on object record, you can still rely on rich text option or as Nirmal suggested you can use formula field., to be more specific with the implementation, you might need two fields:
1) Text/url field which holds url of image from documents or static resources
2) A formula field which can display image in desired height and width by using the value from field 1.

Considering  a scenario, where real user might need to have a way to upload / alter those images, rich text area field will help more.

Thanks,
balaji
This was selected as the best answer
PnasPnas
@ Balaji
trying to capture an image for a record and save it in the attachement .Can u pls help
 
PnasPnas
@ Balaji
trying to capture an image for a record and save as an attachement.Can u pls help