+ Start a Discussion
SabrentSabrent 

Notes and Attachment in VFP

I have a custom object called object__c instead of the standard related list I have a visualfprce page

<pre>
<apex:page standardController="Pobject__c">      

  <apex:form >

<apex:pageblock >
<apex:pageBlockTable Value="{!object__c.NotesAndAttachments}" var="item" columns="4" >

<apex:column HeaderValue="Title"  >   
<apex:outputLink value="/{!item.id}" id="the_link" >
<apex:outputField value="{!item.Title}" />
</apex:outputLink>
</apex:column>
<apex:column HeaderValue="Last Modified Date" >
<apex:outputField value="{!item.LastModifiedDate }" />
</apex:column>
<apex:column HeaderValue="Created By" >
<apex:outputField value="{!item.Createdbyid }" />

</apex:column>

</apex:pageBlockTable>
</apex:pageblock>

</apex:form>


</apex:page>

</pre>

When I click on the attachment link, insetad of opening the attachment , it opens like this


User-added image





Best Answer chosen by Sabrent
SabrentSabrent
Oh !!! I i missed  target= "_blank"


<apex:outputLink value="/{!item.id}" id="the_link"  target= "_blank">

All Answers

clouddev@surashriclouddev@surashri
Hi,

You have to use below link to get/download file

https://c.????.content.force.com/servlet/servlet.FileDownload?file=id

Replace ???? with you server instance and id with your file id.

Thanks,
SabrentSabrent
Thanks, but i don't want to hardcode the url / File id



FYI, If i right click and open in new tab, it opens in a new window correctly

Buy left click opens within the same page instead of openeing in a new window.

Seems like  i am missing something obvious.

SabrentSabrent
Oh !!! I i missed  target= "_blank"


<apex:outputLink value="/{!item.id}" id="the_link"  target= "_blank">
This was selected as the best answer