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

Invoking the text from a text file from the documents tab.

Hi ,


How to invoke the  text from a  text file which is available in the  documents tab in visualforce page.








Documents are objects and can be queried using SOQL. You'll need to query using the Document name or id (or some other identifier) and the text will be in the document body.




When invoking the image we use like this


<apex:image url="/servelet/servelet/id=asawewf343fa34f" />



My question is " how to retrieve the text which is in the text file using the apex code? "


I don want the text file to be opened in a new window.


I m expecting some thing like this.    <apex:output field value=" file name or url of the file" / >










Yeah outputfield or outputtext would do it. And in your apex code you'd have to [SELECT body FROM document WHERE ....]. The 'body' will be a BLOB and you'll convert it to text, which would be returned in a call the ouputtext (or whatever) would make to your apex method.


Make sense?