• marys pinda
  • NEWBIE
  • 45 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 19
    Questions
  • 69
    Replies
I have a code which gets information from a file-URL and creates a Document within the Salesforce.
I wish he created the document on the 10 am and then I used Schedulable.
But he has a problem and does not create the document.
Someone help me please!.

global class UploadFileTest implements System.Schedulable {
 //Public Document mydoc;         
    global void execute(SchedulableContext sc) {
        getFile();
    }
    
 public void  getFile(){
    Http h = new Http();
    HttpRequest req = new HttpRequest();
    req.setEndpoint('http://download.finance.yahoo.com/d/quotes.csv?s=AAPL,IBM&f=sl1d1t1c1ohgv&e=.csv');
    req.setMethod('GET');
    req.setHeader('Content-Type', 'text/csv');
    req.setCompressed(true);
    req.setTimeout(60000);
                  
    HttpResponse res = h.send(req);
    string responseValue = '';
    responseValue = res.getBody();
    system.debug('Response Body for File: ' + responseValue);
    blob image = res.getBodyAsBlob();
 
    Document mydoc = new Document();
    mydoc.Name = 'UPDATE';
    mydoc.Type = 'csv';
    mydoc.folderid = UserInfo.getUserId();
    mydoc.Body = image;
    insert mydoc;       
    }
}
THANK YOU!
Hello,
I have a code which gets information from a file-URL and creates a Document within the Salesforce.
I wish he created the document on the 10 am and then I used Schedulable.
But he has a problem and does not create the document.
Someone help me please!.

global class Test implements System.Schedulable {     
    global void execute(SchedulableContext sc) {
        getFile();
    }
    
 public void  getFile(){
    Http h = new Http();
    HttpRequest req = new HttpRequest();
    string firstImageURL = 'http://download.finance.yahoo.com/d/quotes.csv?s=AAPL,IBM&f=sl1d1t1c1ohgv&e=.csv';
    firstImageURL = firstImageURL.replace(' ', '%20');
    req.setEndpoint(firstImageURL);
    req.setMethod('GET');
    req.setHeader('Content-Type', 'text/csv');
    req.setCompressed(true);
    req.setTimeout(60000);
                  
    HttpResponse res = null;
    res = h.send(req);
    string responseValue = '';
    responseValue = res.getBody();
    system.debug('Response Body for File: ' + responseValue);
    blob image = res.getBodyAsBlob();
 
    Document mydoc = new Document();
    mydoc.Name = 'update today';
    mydoc.Type = 'csv';
    mydoc.folderid = UserInfo.getUserId();
    mydoc.Body = image;
    insert mydoc;       
    }
}
Thank you,
Hello,
I have a file in a URL,
I would like to get  the content of  this file and create a Document.
I made this code, but it does not work, what I forgot to do?

global class UploadFileTest implements System.Schedulable {
 Public Document mydoc;         
    global void execute(SchedulableContext sc) {
        test();
    }
    
public void test(){

Http h = new Http();
HttpRequest req = new HttpRequest();
string firstImageURL = 'download.finance.yahoo.com/d/quotes.csv?s=AAPL,IBM&f=sl1d1t1c1ohgv&e=.csv';
firstImageURL = firstImageURL.replace(' ', '%20');
req.setEndpoint(firstImageURL);
req.setMethod('GET');
req.setHeader('Content-Type', 'text/csv');
req.setCompressed(true);
req.setTimeout(60000);
                 
HttpResponse res = null;
res = h.send(req);
string responseValue = '';
responseValue = res.getBody();
system.debug('Response Body for File: ' + responseValue);
blob image = res.getBodyAsBlob();

mydoc = new Document();
mydoc.Name = 'VOCAZA UPDATE';
mydoc.Type = 'csv';
mydoc.folderid = UserInfo.getUserId();
mydoc.Body = image;
insert mydoc;       
}
}

Thank you
Hello,
Is it possible to develop an Apex class that will take a file on my computer EVERY DAY and it will stored in Salesforce?
How do I do this?
Does anyone have any code for me to follow as a model?

Thank you,
Hello,
I created a custom field of satisfaction with type number.
I made a reques to see what returned me:
select Name,Satisfaction__c from Contact

And I is not got what I wanted:

The desired:
Name, Satisfaction__c
Marcia Morgado, 10
Rosana Moreira, 8
Vanessa Pedrozo, 7

The obtained:
Name, Satisfaction__c
Marcia Morgado, 0032000001E3fVyAAJ
Rosana Moreira, 0032000001D8WWsAAN
Vanessa Pedrozo, 0032000001D8Y4nAAF

CODE:

String query=inputText;
String first=query.substringAfter('select ');  
first=  first.substringBefore('from');
     
    string title= first+'\n';
    string contenuCSV = title;

    string queryResultString = '';
    list<sObject> queryResult = (List<sObject>)database.query(inputText);
    for(sObject a: queryResult)
    {
        queryResultString = queryResultString + string.valueof(a);
    }
    list<string> queryLines = queryResultString.split('}');
    for(string s:queryLines){
        list<string> queryCol = s.split(',');
        for(string st:queryCol){
            contenuCSV = contenuCSV + st.substringAfter('=') + ',';
        }
        contenuCSV = contenuCSV.substringBeforeLast(',').substringBeforeLast(',') + '\n';
    }

How do I solve this problem with numeric fields?
Thank you,
I have a Visualforce page that takes a request and then sends its result by email.
At present, the request is fixed, but I want to use any request.
So goes the question: how do this part to be dynamic:

for(Case a: (List<Case>)database.query(caseTT))
{
   string contenu = a.casenumber + ',' + a.subject+ ',' +a.Contact.Name+ ',' + a.status +'\n';
   contenuCSV = contenuCSV + contenu ;
}


Thank you!

The codes:

PAGE VISUALFORCE::::
<apex:page controller="AAAACSV">
    <style type="text/css">
        .classeRequete { width: 600px; }
        .classeMail { width: 400px; }
    </style>   
  <apex:form >
  <apex:PageBlock >
    Request :&nbsp;&nbsp;<apex:inputText styleClass="classeRequete" value="{!caseTT}"/><br /><br />
    <apex:commandButton value="Valider" action="{!planifier}"/> <br/><br/>
    <apex:commandButton value="Effacer"/> <br/><br/>
  </apex:PageBlock>
  </apex:form>
</apex:page>


CLASS APEX::::
global class AAAACSV implements System.Schedulable {
public string caseTT {get; set;}
  
global void execute(SchedulableContext sc) {
planifier();
}

public void planifier(){
String query = caseTT;
String premier=query.substringAfter('select');     
premier=  premier.substringBefore('from');
string titre= premier+'\n';
string contenuCSV = titre;

for(Case a: (List<Case>)database.query(caseTT))
{
   string contenu = a.casenumber + ',' + a.subject+ ',' +a.Contact.Name+ ',' + a.status +'\n';
   contenuCSV = contenuCSV + contenu ;
}

String lignes = contenuCSV;
List<String> parts = lignes.split('\n');
integer lineNumber = parts.size();

Messaging.EmailFileAttachment csvPJ = new Messaging.EmailFileAttachment();
blob csvBlob = Blob.valueOf(contenuCSV);
nomFichierCSV = 'Closed_'+Date.today().format()+'.csv';
csvPJ.setFileName(nomFichierCSV);
csvPJ.setBody(csvBlob);
Messaging.SingleEmailMessage email =new Messaging.SingleEmailMessage();
String[] adressMail = new list<string> {'mail@mail.com'};
String subject = 'Rreports';
email.setSubject(subject);
email.setToAddresses(adressMail);

email.setPlainTextBody('Mail....);
                        
email.setFileAttachments(new Messaging.EmailFileAttachment[]{csvPJ});
Messaging.SendEmailResult [] envoyer = Messaging.sendEmail(new Messaging.SingleEmailMessage[] {email}); 

}
}

Hello
How can I use a JS function (Visualforce page) within the Controller Apex?

<apex:page controller="AAABCTest">
    <style type="text/css">
        .classeRequete { width: 600px; }
        .classeMail { width: 400px; }
    </style>
    <script type="text/javascript" src="https://raw.github.com/Stuk/jszip/master/jszip.js">
    function create_zip() {
    var zip = new JSZip();
    zip.add("{!JSENCODE(nomFichierCSV)}", "Zip\n");
    content = zip.generate();
   // location.href="data:application/zip;base64," + content;
     </script>
  <apex:form >
  <apex:PageBlock >
    :::::::::: INFOS :::::::::: <br /><br />
    Mail..........:&nbsp;<apex:inputText styleClass="classeMail" value="{!mailSouhaite}"/><br /><br />
    Request :&nbsp;&nbsp;<apex:inputText styleClass="classeRequete" value="{!caseTT}"/><br /><br />
    <apex:commandButton value="Valider" action="{!planifier}"/> <br/><br/>
  </apex:PageBlock>
  </apex:form>
</apex:page>

CONTROLLER:
global class AAABCTest implements System.Schedulable {
public String mailSouhaite {get; set;}
public string caseTT {get; set;}
public string nomFichierCSV {get; set;}
 
global void execute(SchedulableContext sc) {
planifier();
}

public void planifier(){
String query = caseTT;
String premier=query.substringAfter('select');    
premier=  premier.substringBefore('from');
   
string titre= premier+'\n';
string contenuCSV = titre;
  
for(Case a: (List<Case>)database.query(caseTT))
{
   string contenu = a.casenumber + ',' + a.subject+ ',' +a.Contact.Name+ ',' + a.status +'\n';
   contenuCSV = contenuCSV + contenu ;
}

Messaging.EmailFileAttachment csvPJ = new Messaging.EmailFileAttachment();
blob csvBlob = Blob.valueOf(contenuCSV);
nomFichierCSV = 'cases_fermes_'+Date.today().format()+'.csv';
csvPJ.setFileName(nomFichierCSV);
csvPJ.setBody(csvBlob);
Messaging.SingleEmailMessage email =new Messaging.SingleEmailMessage();
String[] adressMail = new list<string> {mailSouhaite};
String subject = 'Rapport Cases Fermés CSV - '+Date.today().format();
email.setSubject(subject);
email.setToAddresses(adressMail);
email.setPlainTextBody('mail...............');

//zip file before to send
//SOMETHING LIKE:::::
create_zip();                   
email.setFileAttachments(new Messaging.EmailFileAttachment[]{csvPJ});
Messaging.SendEmailResult [] envoyer = Messaging.sendEmail(new Messaging.SingleEmailMessage[] {email});

}
}

Thank you,
Hi,

Is it possible to use the value of a string as a type?
How do I do this?
Thank you

Example:
String aaa = 'Case';
for(aaa a: (List<aaa>)database.query(stringQuery))
=
for(Case a: (List<Case>)database.query(stringQuery))
Is it possible to send a file attachment that contains only 10 lines?
If the file has more than 10 lines (30 lines for example), send a second email and a third email.

Many emails with the same file divided into 3 parts:
Email 1 - Part 1
Email 2 - Part 2
Email 3 - Part 3

Thank you,

global class AAAACSV implements System.Schedulable {
public String mailSouhaite {get; set;}
public string caseTT {get; set;}
    
global void execute(SchedulableContext sc) {
planifier();
}

public void planifier(){
String query = caseTT;
String premier=query.substringAfter('select');     
premier=  premier.substringBefore('from');
    
string titre= premier+'\n';
string contenuCSV = titre; 
string contenu;
    
for(Case a: (List<Case>)database.query(caseTT))
{    
    contenu = a.casenumber + ',' + a.subject+ ',' +a.Contact.Name+ ',' + a.status +'\n';
    contenuCSV = contenuCSV + contenu ;
}

Messaging.EmailFileAttachment csvPJ = new Messaging.EmailFileAttachment();
blob csvBlob = Blob.valueOf(contenuCSV);
string csvNom = 'cases_fermes_'+Date.today().format()+'.csv';
csvPJ.setFileName(csvNom);
csvPJ.setBody(csvBlob);
Messaging.SingleEmailMessage email =new Messaging.SingleEmailMessage();
String[] adressMail = new list<string> {mailSouhaite};
String subject = 'CSV - '+Date.today().format();
email.setSubject(subject);
email.setToAddresses(adressMail);

String lignes = contenuCSV;
List<String> parts = lignes.split('\n');
integer lineNumber = parts.size();

if (lineNumber >=10){
//???????????????????????????
email.setPlainTextBody('mail....................');     
email.setFileAttachments(new Messaging.EmailFileAttachment[]{csvPJ});
Messaging.SendEmailResult [] envoyer = Messaging.sendEmail(new Messaging.SingleEmailMessage[] {email}); 

}//if
}
}

Hi..
I would like to make bold part be dynamic.
It's simple: take any request  informed in input text and uses it correctly.
I have to make the input text receiving any request and work.

I want not just Cases, I want Leads, Opportunity, Contacts request ...
Thank you!

CONTROLLER:
global class AAAACSV implements System.Schedulable {
public String mailSouhaite {get; set;}
public string caseTT {get; set;}
  
global void execute(SchedulableContext sc) {
planifier();
}

public void planifier(){
String query = caseTT;
String premier=query.substringAfter('select');   
premier=  premier.substringBefore('from');
  
string titre= premier+'\n';
string contenuCSV = titre;

//BE DYNAMIQUE??? IS IT POSSIBLE???
for(Case a: (List<case>)database.query(caseTT))
{
   string contenu = a.casenumber + ',' + a.subject+ ',' +a.Contact.Name+ ',' + a.status +'\n';
   contenuCSV = contenuCSV + contenu ;
}


Messaging.EmailFileAttachment csvPJ = new Messaging.EmailFileAttachment();
blob csvBlob = Blob.valueOf(contenuCSV);
string csvNom = 'cases_closed_'+Date.today().format()+'.csv';
csvPJ.setFileName(csvNom);
csvPJ.setBody(csvBlob);
Messaging.SingleEmailMessage email =new Messaging.SingleEmailMessage();
String[] adressMail = new list<string> {mailSouhaite};
String subject = 'Report - '+Date.today().format();
email.setSubject(subject);
email.setToAddresses(adressMail);

email.setPlainTextBody('mail..........');             
email.setFileAttachments(new Messaging.EmailFileAttachment[]{csvPJ});
Messaging.SendEmailResult [] envoyer = Messaging.sendEmail(new Messaging.SingleEmailMessage[] {email});
}
}

PAGE:
<apex:page controller="AAAACSV">
    <style type="text/css">
        .classeRequete { width: 600px; }
        .classeMail { width: 400px; }
    </style>
  <apex:form >
  <apex:PageBlock >
    :::::::::: PARAMETRAGE :::::::::: <br /><br />
    Mail..........:&nbsp;<apex:inputText styleClass="classeMail" value="{!mailSouhaite}"/><br /><br />
    Requête :&nbsp;&nbsp;<apex:inputText styleClass="classeRequete" value="{!caseTT}"/><br /><br />
    <apex:commandButton value="Valider" action="{!planifier}"/> <br/><br/>
    <apex:commandButton value="Effacer"/> <br/><br/>
  </apex:PageBlock>
  </apex:form>
</apex:page>
Is it possible to divise the attachment file in many email (same address) ?

For exemple, the file to send is 10MB and I want to send files with max 1MB,
so I would like how do I divise this file for to send 10 emails to the same person with the complete content.

Thank you,
Is it possible to count the number of lines in an attached file in the email?

Thank you!

Messaging.EmailFileAttachment csvPJ = new Messaging.EmailFileAttachment();
blob csvBlob = Blob.valueOf(contenuCSV);
string csvNom = 'cases_fermes_'+Date.today().format()+'.csv';
csvPJ.setFileName(csvNom);
csvPJ.setBody(csvBlob);
Messaging.SingleEmailMessage email =new Messaging.SingleEmailMessage();
String[] adressMail = new list<string> {mailSouhaite};
String subject = 'Report - '+Date.today().format();
email.setSubject(subject);
email.setToAddresses( adressMail );

email.setPlainTextBody('mail....');
email.setFileAttachments(new Messaging.EmailFileAttachment[]{csvPJ});
Messaging.SendEmailResult [] envoyer = Messaging.sendEmail(new Messaging.SingleEmailMessage[] {email});
Somethig like: csvPJ.getLineNumber();

Thank you
Is it possible to pick values ​​between SELECT and FROM (String) and use the code in Apex?

Example: the user informe = SELECT casenumber,subject,Contact.Name,status FROM Case WHERE ClosedDate=TODAY
The Apex code uses only: casenumber, subject, Contact.Name, status to build a CSV::::

...
string titre= 'casenumber,subject,Contact.Name,status'+'\n';

...

for(Case a: (List<case>)database.query(caseTT) )
{
   string contenu = a.casenumber + ',' + a.subject+ ',' +a.Contact.Name+ ',' + a.status +'\n';
   contenuCSV = contenuCSV + contenu ;
}

....

Thank you!!!
Is it possible to compare the system time with the time for a JOB?
Something like:

global class AAAExporterCSV implements System.Schedulable {
global void execute(SchedulableContext sc) {
List<case> caseFermeList = [Select casenumber,subject,Contact.Name,status from case where closeddate=TODAY];
string titre= 'Id, Subject,Demandeur,Status'+'\n';
string contenuCSV = titre;
for(Case a: caseFermeList )
if(DateTime.Now() == SCHEDULABLEJOB.Time){
if(a.closeddate == system.Today()){
{
   string contenu = a.casenumber + ',' + a.subject+ ',' +a.Contact.Name+ ',' + a.status +'\n';
   contenuCSV = contenuCSV + contenu ;
}
Messaging.EmailFileAttachment csvPJ = new Messaging.EmailFileAttachment();
blob csvBlob = Blob.valueOf(contenuCSV);
string csvNom = 'cases_fermes.csv';
csvPJ.setFileName(csvNom);
csvPJ.setBody(csvBlob);
Messaging.SingleEmailMessage email =new Messaging.SingleEmailMessage();
String[] adressMail = new list<string> {'v.u@uoly.com'};
String subject = 'report';
email.setSubject(subject);
email.setToAddresses( adressMail );
email.setPlainTextBody('Hi ....');
email.setFileAttachments(new Messaging.EmailFileAttachment[]{csvPJ});
Messaging.SendEmailResult [] envoyer = Messaging.sendEmail(new Messaging.SingleEmailMessage[] {email});
  }
  }
  }
}



Thank you!
Hiii,

It is possible an apex class to create a CSV file and after to zip the CSV file into a zip file?

I read many forums but not found answers.

Thank you,
Hello,

It is possible to enter a request SOQL in input text of a Visualforce page and after use this request in Apex class?
How do I do this?

I tried this, but that didn't work:

APEX CLASS:
....
public List<case> caseTT {get; set;}
.....
List<case> caseFermeList = caseTT ;

VISUALFORCE:
.....
Request : <apex:inputText value="{!caseTT}"/><br /><br />

Thank you!!!
Hello,
I have an Apex class that generates a CSV file.

global class AAAExporterCSV implements System.Schedulable {
global void execute(SchedulableContext sc) {
List<case> acclist = [Select casenumber,subject, accountid from case where closeddate=TODAY];
string header = 'Id, Subject,Account, '+'\n';
string finalstr = header ;
for(case a: acclist)
{
   string recordString = a.casenumber + ',' + a.subject+ ',' + a.accountid +'\n';
   finalstr = finalstr + recordString;
}
Messaging.EmailFileAttachment csvAttc = new Messaging.EmailFileAttachment();
blob csvBlob = Blob.valueOf(finalstr);
string csvname= 'cases.csv';
csvAttc.setFileName(csvname);
csvAttc.setBody(csvBlob);
Messaging.SingleEmailMessage email =new Messaging.SingleEmailMessage();
String[] toAddresses = new list<string> {'v.veve@veve.com'};
String subject = 'Report CSV';
email.setSubject(subject);
email.setToAddresses( toAddresses );
email.setPlainTextBody('The Merchandise report is attached here.');
email.setFileAttachments(new Messaging.EmailFileAttachment[]{csvAttc});
Messaging.SendEmailResult [] r = Messaging.sendEmail(new Messaging.SingleEmailMessage[] {email});
  }
}

I wonder how do I put this CSV (cases.csv) within a ZIP and to send an email.
It is possible to do in the same class?

It's correct: ... where closeddate=TODAY ???
Thank you,
I tried exporting data using Apex (http://salesforceapexcodecorner.blogspot.fr/2012/03/export-in-csv-and-excel-in-apex.html).
But I have an error and not think solution for it on the internet.
Someone help me?

Thank you
Hello,

How do I export my CASES in command line?
I used this tutorial but in the end has many errors:::: http://www.shivasoft.in/blog/salesforce/tutorial-of-command-line-dataloader-salesforce/

Another thing is to make a FTP connection in Apex? I want to export in CSV my CASES and puts them on the FTP server.

Thank you,
Hello,
I created a custom field of satisfaction with type number.
I made a reques to see what returned me:
select Name,Satisfaction__c from Contact

And I is not got what I wanted:

The desired:
Name, Satisfaction__c
Marcia Morgado, 10
Rosana Moreira, 8
Vanessa Pedrozo, 7

The obtained:
Name, Satisfaction__c
Marcia Morgado, 0032000001E3fVyAAJ
Rosana Moreira, 0032000001D8WWsAAN
Vanessa Pedrozo, 0032000001D8Y4nAAF

CODE:

String query=inputText;
String first=query.substringAfter('select ');  
first=  first.substringBefore('from');
     
    string title= first+'\n';
    string contenuCSV = title;

    string queryResultString = '';
    list<sObject> queryResult = (List<sObject>)database.query(inputText);
    for(sObject a: queryResult)
    {
        queryResultString = queryResultString + string.valueof(a);
    }
    list<string> queryLines = queryResultString.split('}');
    for(string s:queryLines){
        list<string> queryCol = s.split(',');
        for(string st:queryCol){
            contenuCSV = contenuCSV + st.substringAfter('=') + ',';
        }
        contenuCSV = contenuCSV.substringBeforeLast(',').substringBeforeLast(',') + '\n';
    }

How do I solve this problem with numeric fields?
Thank you,
Hello,
I have a code which gets information from a file-URL and creates a Document within the Salesforce.
I wish he created the document on the 10 am and then I used Schedulable.
But he has a problem and does not create the document.
Someone help me please!.

global class Test implements System.Schedulable {     
    global void execute(SchedulableContext sc) {
        getFile();
    }
    
 public void  getFile(){
    Http h = new Http();
    HttpRequest req = new HttpRequest();
    string firstImageURL = 'http://download.finance.yahoo.com/d/quotes.csv?s=AAPL,IBM&f=sl1d1t1c1ohgv&e=.csv';
    firstImageURL = firstImageURL.replace(' ', '%20');
    req.setEndpoint(firstImageURL);
    req.setMethod('GET');
    req.setHeader('Content-Type', 'text/csv');
    req.setCompressed(true);
    req.setTimeout(60000);
                  
    HttpResponse res = null;
    res = h.send(req);
    string responseValue = '';
    responseValue = res.getBody();
    system.debug('Response Body for File: ' + responseValue);
    blob image = res.getBodyAsBlob();
 
    Document mydoc = new Document();
    mydoc.Name = 'update today';
    mydoc.Type = 'csv';
    mydoc.folderid = UserInfo.getUserId();
    mydoc.Body = image;
    insert mydoc;       
    }
}
Thank you,
i have three custom objects.

Bank_Account__c(Parent) --->Bank_transaction__c(child)

Bank_Account__c(Parent) --->Bank_statement__c(child)

Bank_transaction__c fields are date__c, credit__c, debit__c

Bank_statement__c fields are start_date__c, end_date__c

I just want to write a single query to get the records of Bank_transaction__c which date__c is in between start_date__c and end_date__c of bank_statement__c object. How can i achieve this
Hello,
I have a file in a URL,
I would like to get  the content of  this file and create a Document.
I made this code, but it does not work, what I forgot to do?

global class UploadFileTest implements System.Schedulable {
 Public Document mydoc;         
    global void execute(SchedulableContext sc) {
        test();
    }
    
public void test(){

Http h = new Http();
HttpRequest req = new HttpRequest();
string firstImageURL = 'download.finance.yahoo.com/d/quotes.csv?s=AAPL,IBM&f=sl1d1t1c1ohgv&e=.csv';
firstImageURL = firstImageURL.replace(' ', '%20');
req.setEndpoint(firstImageURL);
req.setMethod('GET');
req.setHeader('Content-Type', 'text/csv');
req.setCompressed(true);
req.setTimeout(60000);
                 
HttpResponse res = null;
res = h.send(req);
string responseValue = '';
responseValue = res.getBody();
system.debug('Response Body for File: ' + responseValue);
blob image = res.getBodyAsBlob();

mydoc = new Document();
mydoc.Name = 'VOCAZA UPDATE';
mydoc.Type = 'csv';
mydoc.folderid = UserInfo.getUserId();
mydoc.Body = image;
insert mydoc;       
}
}

Thank you
Hello,
Is it possible to develop an Apex class that will take a file on my computer EVERY DAY and it will stored in Salesforce?
How do I do this?
Does anyone have any code for me to follow as a model?

Thank you,
Hello,
I created a custom field of satisfaction with type number.
I made a reques to see what returned me:
select Name,Satisfaction__c from Contact

And I is not got what I wanted:

The desired:
Name, Satisfaction__c
Marcia Morgado, 10
Rosana Moreira, 8
Vanessa Pedrozo, 7

The obtained:
Name, Satisfaction__c
Marcia Morgado, 0032000001E3fVyAAJ
Rosana Moreira, 0032000001D8WWsAAN
Vanessa Pedrozo, 0032000001D8Y4nAAF

CODE:

String query=inputText;
String first=query.substringAfter('select ');  
first=  first.substringBefore('from');
     
    string title= first+'\n';
    string contenuCSV = title;

    string queryResultString = '';
    list<sObject> queryResult = (List<sObject>)database.query(inputText);
    for(sObject a: queryResult)
    {
        queryResultString = queryResultString + string.valueof(a);
    }
    list<string> queryLines = queryResultString.split('}');
    for(string s:queryLines){
        list<string> queryCol = s.split(',');
        for(string st:queryCol){
            contenuCSV = contenuCSV + st.substringAfter('=') + ',';
        }
        contenuCSV = contenuCSV.substringBeforeLast(',').substringBeforeLast(',') + '\n';
    }

How do I solve this problem with numeric fields?
Thank you,
I have a Visualforce page that takes a request and then sends its result by email.
At present, the request is fixed, but I want to use any request.
So goes the question: how do this part to be dynamic:

for(Case a: (List<Case>)database.query(caseTT))
{
   string contenu = a.casenumber + ',' + a.subject+ ',' +a.Contact.Name+ ',' + a.status +'\n';
   contenuCSV = contenuCSV + contenu ;
}


Thank you!

The codes:

PAGE VISUALFORCE::::
<apex:page controller="AAAACSV">
    <style type="text/css">
        .classeRequete { width: 600px; }
        .classeMail { width: 400px; }
    </style>   
  <apex:form >
  <apex:PageBlock >
    Request :&nbsp;&nbsp;<apex:inputText styleClass="classeRequete" value="{!caseTT}"/><br /><br />
    <apex:commandButton value="Valider" action="{!planifier}"/> <br/><br/>
    <apex:commandButton value="Effacer"/> <br/><br/>
  </apex:PageBlock>
  </apex:form>
</apex:page>


CLASS APEX::::
global class AAAACSV implements System.Schedulable {
public string caseTT {get; set;}
  
global void execute(SchedulableContext sc) {
planifier();
}

public void planifier(){
String query = caseTT;
String premier=query.substringAfter('select');     
premier=  premier.substringBefore('from');
string titre= premier+'\n';
string contenuCSV = titre;

for(Case a: (List<Case>)database.query(caseTT))
{
   string contenu = a.casenumber + ',' + a.subject+ ',' +a.Contact.Name+ ',' + a.status +'\n';
   contenuCSV = contenuCSV + contenu ;
}

String lignes = contenuCSV;
List<String> parts = lignes.split('\n');
integer lineNumber = parts.size();

Messaging.EmailFileAttachment csvPJ = new Messaging.EmailFileAttachment();
blob csvBlob = Blob.valueOf(contenuCSV);
nomFichierCSV = 'Closed_'+Date.today().format()+'.csv';
csvPJ.setFileName(nomFichierCSV);
csvPJ.setBody(csvBlob);
Messaging.SingleEmailMessage email =new Messaging.SingleEmailMessage();
String[] adressMail = new list<string> {'mail@mail.com'};
String subject = 'Rreports';
email.setSubject(subject);
email.setToAddresses(adressMail);

email.setPlainTextBody('Mail....);
                        
email.setFileAttachments(new Messaging.EmailFileAttachment[]{csvPJ});
Messaging.SendEmailResult [] envoyer = Messaging.sendEmail(new Messaging.SingleEmailMessage[] {email}); 

}
}

Hi..
I would like to make bold part be dynamic.
It's simple: take any request  informed in input text and uses it correctly.
I have to make the input text receiving any request and work.

I want not just Cases, I want Leads, Opportunity, Contacts request ...
Thank you!

CONTROLLER:
global class AAAACSV implements System.Schedulable {
public String mailSouhaite {get; set;}
public string caseTT {get; set;}
  
global void execute(SchedulableContext sc) {
planifier();
}

public void planifier(){
String query = caseTT;
String premier=query.substringAfter('select');   
premier=  premier.substringBefore('from');
  
string titre= premier+'\n';
string contenuCSV = titre;

//BE DYNAMIQUE??? IS IT POSSIBLE???
for(Case a: (List<case>)database.query(caseTT))
{
   string contenu = a.casenumber + ',' + a.subject+ ',' +a.Contact.Name+ ',' + a.status +'\n';
   contenuCSV = contenuCSV + contenu ;
}


Messaging.EmailFileAttachment csvPJ = new Messaging.EmailFileAttachment();
blob csvBlob = Blob.valueOf(contenuCSV);
string csvNom = 'cases_closed_'+Date.today().format()+'.csv';
csvPJ.setFileName(csvNom);
csvPJ.setBody(csvBlob);
Messaging.SingleEmailMessage email =new Messaging.SingleEmailMessage();
String[] adressMail = new list<string> {mailSouhaite};
String subject = 'Report - '+Date.today().format();
email.setSubject(subject);
email.setToAddresses(adressMail);

email.setPlainTextBody('mail..........');             
email.setFileAttachments(new Messaging.EmailFileAttachment[]{csvPJ});
Messaging.SendEmailResult [] envoyer = Messaging.sendEmail(new Messaging.SingleEmailMessage[] {email});
}
}

PAGE:
<apex:page controller="AAAACSV">
    <style type="text/css">
        .classeRequete { width: 600px; }
        .classeMail { width: 400px; }
    </style>
  <apex:form >
  <apex:PageBlock >
    :::::::::: PARAMETRAGE :::::::::: <br /><br />
    Mail..........:&nbsp;<apex:inputText styleClass="classeMail" value="{!mailSouhaite}"/><br /><br />
    Requête :&nbsp;&nbsp;<apex:inputText styleClass="classeRequete" value="{!caseTT}"/><br /><br />
    <apex:commandButton value="Valider" action="{!planifier}"/> <br/><br/>
    <apex:commandButton value="Effacer"/> <br/><br/>
  </apex:PageBlock>
  </apex:form>
</apex:page>