0

In my visualforce page, having a section called 'Loan Documents' below it contains attachment. Need to download those attachment.

7
  • Click on the 'view' button next to the attachment.
    – Prajith
    Commented May 24, 2016 at 3:39
  • Thanks @stygon. But the view button show the document as new tab. Is there possible to download it. Please explain abut the possibilities in codes aswell
    – parthipan
    Commented May 24, 2016 at 4:16
  • Let's try right click - save link as
    – Prajith
    Commented May 24, 2016 at 4:17
  • Yes Stygon. i tried this works very well. But here i want to do it by clicking on Button - 'Download'. I am having limited experience in both visaulforce and apex.
    – parthipan
    Commented May 24, 2016 at 7:23
  • public PageReference getfile(){ if(uploadHistoryList.size() != null){ uploadHistory = [SELECT genesis_Account_Id__c, genesis_Application_Id__c, Loan_App_Id__c, Product_Related_Doc_Name__c, Document_URL__c, is_Doc_Verified__c, FROM Upload_History__c WHERE genesis_Application_Id__c =: application.Id AND Loan_App_Id__c =: loanApplication.Loan_ID__c ]; Attachment attachment = [SELECT Id, Body, ContentType, Name, ParentId FROM Attachment WHERE ParentId =: application.Id AND Name =: docNameForAction]; return null; }
    – parthipan
    Commented May 24, 2016 at 10:10

2 Answers 2

2

try this:

<apex:outputLink value="{!URLFOR($Action.Attachment.Download, YOURATTACHEMENTID)}" target="_blank">Download</apex:outputLink>

We use global action on attachment to allows download with stay in the same page.

0
0

try that (it works for me)

  <apex:outputLink value="https://c.eu2.visual.force.com/{!Attachment ID here}" target="_blank">Download</apex:outputLink>

change https://c.eu2.visual.force.com/ by your organization link.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .