function readOnly(count){ }
Don't have an account?
Search for an answer or ask a question of the zone or Customer Support.
You need to sign in to do that
Sign in to start searching questions
Signup for a Developer Edition
Sign in to start a discussion
Hi
I need to create a custom button that generate a flat file .txt
is there any method to create a file on apex code?
Thanks for your help
d.id will contain the ID of the file you just saved (starting with the line insert d).
You can write to a string, and save that string as a blob, or output the string in a visualforce page. By setting the contentType of a visualforce page to "text/plain", you can dump out the file as plain text.
Thanks
I created a custom buttom that execute an apex method.
this method create the file (document d = new document();.......) and must return the url.
global class GenerateFile {
WebService static string Generer(string adr) {
Document d=new Document();
//d.FolderId='005d0000000bWCG';d.FolderId=UserInfo.getUserId();d.Name = 'my text file';String myContent = 'ADDRESSSE : '+adr;d.Body = Blob.valueOf(myContent);d.ContentType = 'text/plain';d.Type = 'txt';
insert d;string IdFichier=''; // id file
string chemin='/servlet/servlet.FileDownload?file='+IdFichier;
return chemin;
}}
how can i get the idFile ????
Thanks it works :smileyvery-happy:
d.id will contain the ID of the file you just saved (starting with the line insert d).
All Answers
You can write to a string, and save that string as a blob, or output the string in a visualforce page. By setting the contentType of a visualforce page to "text/plain", you can dump out the file as plain text.
Thanks
I created a custom buttom that execute an apex method.
this method create the file (document d = new document();.......) and must return the url.
global class GenerateFile {
WebService static string Generer(string adr) {
Document d=new Document();
//d.FolderId='005d0000000bWCG';
d.FolderId=UserInfo.getUserId();
d.Name = 'my text file';
String myContent = 'ADDRESSSE : '+adr;
d.Body = Blob.valueOf(myContent);
d.ContentType = 'text/plain';
d.Type = 'txt';
insert d;
string IdFichier=''; // id file
string chemin='/servlet/servlet.FileDownload?file='+IdFichier;
return chemin;
}
}
how can i get the idFile ????
d.id will contain the ID of the file you just saved (starting with the line insert d).
Thanks it works :smileyvery-happy: