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

View Document in custom link

Hi every one..,


 I uploaded a document in documents tab in a folder.., and i want to link it to custom link .., 


when i click it has to open and view the corresponding document .., but it should not donwload the document.. 


Is it possible in salesforce?? please help..; its urgent.. 





A document is just another SF object type so you can just build a link using the ID of the document. If you query for the documents you need just build a link with a value = '/DOC_OBJECT_ID_HERE'.


<apex:outputLink value="/DOC_OBJECT_ID" target="_blank">Click here for the document</apex:outputLink>


The outputLink tag will render as a standard HTML anchor tag so you can use the "target" attribute to make the document open in a new tab if you want.


Hello DaveH..,


      Thanks for your reply..., When we use '/ObjectId' .., it reroutes to the detail page that contains document .., but it will not going to open the document.., 


salesforce has given the default link to download it .., the link will be like this:


"https:/orgID/servlet/servlet.FileDownload?File = docId"..., but if we click it .. we will download the file.., 


i dont want to downloadit.., i have to open straight away.., do you know what i mean?







When you say you want to "open it straight away" do you mean you want it to pull up as a preview in the browser? Either way you are technically downloading the file because it is hosted on Salesforce. You download it to the user's machine or download it to display in a browser window (such as a PDF or image). 

i want to download it to diplay in a browse window (as pdf or image)