I've built a visualforce page that has a button that creates and stores a text file as an attachment on a custom object. I'd like for this text file to be available as a download link on the visualforce page, but am having issues creating this download link.

Has anyone done this before? Is it possible?

1 Answer 1


Yes, it's possible. You just need to query the attachment record or otherwise obtain its ID, then construct a link to it:

<a  download="{!AttachmentName}" 
    href="{!URLFOR($Action.Attachment.Download, AttachmentId)}">

You may need to make some adjustments to this, but it should work without too much modification.

You must log in to answer this question.

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