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
marys pindamarys pinda 

Request SOQL input text Visualforce

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!!!
Best Answer chosen by marys pinda
kiranmutturukiranmutturu
try this and let me  know

global class AAAExporterCSV2 implements System.Schedulable {
public String mailSouhaite {get; set;}
public string caseTT {get; set;}

global void execute(SchedulableContext sc) {
planifier();
}

public void planifier(){
string titre= 'Id, Subject,Demandeur,Status'+'\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);
string csvNom = 'cases_fermes.csv';
csvPJ.setFileName(csvNom);
csvPJ.setBody(csvBlob);
Messaging.SingleEmailMessage email =new Messaging.SingleEmailMessage();
String[] adressMail = new list<string> {mailSouhaite};
String subject = 'Rapport Cases Fermés CSV';
email.setSubject(subject);
email.setToAddresses( adressMail );
email.setPlainTextBody('Bonjour\n\nIl y a des Cases qui se sont fermés!\nCi-joint un rapport avec les informations des Cases fermés.\n\nCordialement, Vocaza');
email.setFileAttachments(new Messaging.EmailFileAttachment[]{csvPJ});
Messaging.SendEmailResult [] envoyer = Messaging.sendEmail(new Messaging.SingleEmailMessage[] {email});
  }
}

My page Visualforce

<apex:page controller="AAAExporterCSV2">
  <apex:form >
  <apex:PageBlock >
    :::::::::: PARAMETRAGE :::::::::: <br /><br />
    Mail :<apex:inputText value="{!mailSouhaite}"/><br /><br />
    Requête :<apex:inputText value="{!caseTT}"/><br /><br />
    <apex:commandButton value="Valider" action="{!planifier}"/> <br/><br/>
    <apex:commandButton value="Effacer"/> <br/><br/>
  </apex:PageBlock>
  </apex:form>
</apex:page>

All Answers

kiranmutturukiranmutturu
Use this component to get user input for a controller method that does not correspond to a field on a Salesforce object.. 
marys pindamarys pinda
I don't understand!
kiranmutturukiranmutturu
inputtext will not take merge fileds which associated to standard objects like in your case it is case. Why can't you use inputfield?
marys pindamarys pinda
Thank you...

I don't know how to use inputField to retrieve data from a SOQL request ...
kiranmutturukiranmutturu
what exactly the scenario that you want to implement?

marys pindamarys pinda
I would you like to use email and request , after send to the email you entered a CSV with the result of the request.

User-added image
kiranmutturukiranmutturu
sorry I didn't get you what you are trying to explain?
marys pindamarys pinda
I only want to get: EMAIL and REQUEST the Visualforce page.

Passe the values ​​EMAIL and REQUEST for an APEX class.
The APEX class will send an email to the email entered in Visualforce page with a CSV with the results of the REQUEST.

OK?
Thank you
kiranmutturukiranmutturu
this is a sample .. you need to map this approach with your requirement..

public class className
{
 public string email{get;set;}
 
 public void sendEmail()
 {
	if(email != null)
	{
		send email functionality
		
		if you need to send to email with case object details
		
		Case objC = [select id, casenumber so on... from case where email = :ContactEmail];
		
		then use the objc in the process
	}
 }
}



<apex:page>
<apex:form>
	Email:  <apex:inputText value ="{!email}"/>
</apex:form>
</apex:page>


marys pindamarys pinda
Thank you!
But it's possible to get the value entered (REQUEST) in the input text and to use him to controller?

For email I got to do ... but for the request I dont know how I do!
kiranmutturukiranmutturu
what type of value that users will enter in request? what exactly is that?
marys pindamarys pinda
The User will enter into input text:
EMAIL: flower@uol.com
REQUEST: Select casenumber, subject, Contact.Name, status from case where closeddate = TODAY
marys pindamarys pinda
My class:

global class AAAExporterCSV2 implements System.Schedulable {
public String mailSouhaite {get; set;}
public List<case> caseTT {get; set;}

global void execute(SchedulableContext sc) {
planifier();
}

public void planifier(){
List<case> caseFermeList = caseTT ;
string titre= 'Id, Subject,Demandeur,Status'+'\n';
string contenuCSV = titre;
for(Case a: caseFermeList )
{
   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> {mailSouhaite};
String subject = 'Rapport Cases Fermés CSV';
email.setSubject(subject);
email.setToAddresses( adressMail );
email.setPlainTextBody('Bonjour\n\nIl y a des Cases qui se sont fermés!\nCi-joint un rapport avec les informations des Cases fermés.\n\nCordialement, Vocaza');
email.setFileAttachments(new Messaging.EmailFileAttachment[]{csvPJ});
Messaging.SendEmailResult [] envoyer = Messaging.sendEmail(new Messaging.SingleEmailMessage[] {email});
  }
}

My page Visualforce

<apex:page controller="AAAExporterCSV2">
  <apex:form >
  <apex:PageBlock >
    :::::::::: PARAMETRAGE :::::::::: <br /><br />
    Mail :<apex:inputText value="{!mailSouhaite}"/><br /><br />
    Requête :<apex:inputText value="{!caseTT}"/><br /><br />
    <apex:commandButton value="Valider" action="{!planifier}"/> <br/><br/>
    <apex:commandButton value="Effacer"/> <br/><br/>
  </apex:PageBlock>
  </apex:form>
</apex:page>
kiranmutturukiranmutturu
try this and let me  know

global class AAAExporterCSV2 implements System.Schedulable {
public String mailSouhaite {get; set;}
public string caseTT {get; set;}

global void execute(SchedulableContext sc) {
planifier();
}

public void planifier(){
string titre= 'Id, Subject,Demandeur,Status'+'\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);
string csvNom = 'cases_fermes.csv';
csvPJ.setFileName(csvNom);
csvPJ.setBody(csvBlob);
Messaging.SingleEmailMessage email =new Messaging.SingleEmailMessage();
String[] adressMail = new list<string> {mailSouhaite};
String subject = 'Rapport Cases Fermés CSV';
email.setSubject(subject);
email.setToAddresses( adressMail );
email.setPlainTextBody('Bonjour\n\nIl y a des Cases qui se sont fermés!\nCi-joint un rapport avec les informations des Cases fermés.\n\nCordialement, Vocaza');
email.setFileAttachments(new Messaging.EmailFileAttachment[]{csvPJ});
Messaging.SendEmailResult [] envoyer = Messaging.sendEmail(new Messaging.SingleEmailMessage[] {email});
  }
}

My page Visualforce

<apex:page controller="AAAExporterCSV2">
  <apex:form >
  <apex:PageBlock >
    :::::::::: PARAMETRAGE :::::::::: <br /><br />
    Mail :<apex:inputText value="{!mailSouhaite}"/><br /><br />
    Requête :<apex:inputText value="{!caseTT}"/><br /><br />
    <apex:commandButton value="Valider" action="{!planifier}"/> <br/><br/>
    <apex:commandButton value="Effacer"/> <br/><br/>
  </apex:PageBlock>
  </apex:form>
</apex:page>
This was selected as the best answer
marys pindamarys pinda
Did not work!
marys pindamarys pinda
YES it worked ....
THANK YOU TOO!

The email took to reach!