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
poo24poo24 

How to get the url of an image uploaded on a visualforce page on a custom field created in Leads

I have created a visualforec page "MY Files" for uploading Images.

Then i Customized Leads and added a custom button on leads which redirects to the above Visualforce page.

Image is uploaded....and when we click on view file...image is being shown.....

 

Now what i need to do is,i want to get the url of any of these images uploaded on Leads where i have custom fields which would hold the particular Image type url's respectivley.

Like for example.... if i have uploaded a base image then the custom field : Base Image in Leads will hold the url of this image type......and if i have uploaded a sample pic then the custom field : Sample Image will hold the url of that image.

 

Any help would be appreciated !!

Thanks

 

 

Navatar_DbSupNavatar_DbSup

Hi,

 

When you are saving an image in salesforce then salesforce gives a salesforce id of that document. You can just save the document id with url in your Lead custom field.

 

You save the image url like:

/servlet/servlet.FileDownload?file=  ‘salesforce generated document id ’

 

Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved. 

 

 

 

poo24poo24

Hi Ankit,

 

Ya i did that... but i dont know wats gng wrong with my code : i need to get this url in the custom field of Leads !!

 

public class VFFileUpload
{
public Id recId
{ get;set; }

public VFFileUpload(ApexPages.StandardController Lead)
{
recId = lead.getRecord().Id;
}

public string fileName
{ get;set; }

public Blob fileBody
{ get;set; }

public PageReference UploadFile()
{
PageReference pr;
if(fileBody != null && fileName != null)
{
Attachment myAttachment = new Attachment();
myAttachment.Body = fileBody;
myAttachment.Name = fileName;
myAttachment.ParentId = recId;

insert myAttachment;
pr = new PageReference('/' + myAttachment.Id);
pr.setRedirect(true);
return pr;

string value = ApexPages.currentPage().getParameters().get('id');
lead [] acctsList = [SELECT Id FROM lead WHERE id=:value];
for (lead a : acctsList) {
a.OverlayImage_URL__c='https://c.ap1.content.force.com/servlet/servlet.FileDownload?file=00P900000024bPV';}
}
return null;
}
}