You need to sign in to do that
Don't have an account?
Eelco Litjens
lookup training participant based on email address
Hi all,
we have had devlopment done for us, but not anymore, and i'm trying to change a VF page and controller to lookup a training participant based upon his/her email address.
What do i have to change to search on email instead of D-Number. can anyone help me out?
the controller i have now is:
"
public class TrainingController {
String searchText;
List<Deelnemer_Evenement_Training__c> results;
public String getSearchText() {
return searchText;
}
public void setSearchText(String s) {
searchText = s;
}
public List<Deelnemer_Evenement_Training__c> getResults() {
return results;
}
public PageReference doSearch() {
results = (List<Deelnemer_Evenement_Training__c>)[FIND :searchText RETURNING Deelnemer_Evenement_Training__c(First_name__c, Last_name__c, E_mail_deelnemer__c, Evenement_Trainings_sessie__c)][0];
return null;
}
public String participantId {get; set;}
public boolean reset {get; set;}
public boolean alreadyAttending {get; set;}
public boolean UpdateError {get; set;}
public boolean Updated {get; set;}
public Deelnemer_Evenement_Training__c participantion {get; set;}
public TrainingController(){
reset = false;
alreadyAttending = false;
Updated = false;
UpdateError = false;
participantId = '';
}
public pageReference getRegistration ()
{
reset = true;
Updated = false;
string participantIdSQL = 'D-'+participantId;
alreadyAttending = false;
participantion = new Deelnemer_Evenement_Training__c();
try{
participantion = [SELECT /*Event / Trainings session */
Evenement_Trainings_sessie__r.name,
Evenement_Trainings_sessie__r.Startdatum__c, /*start Date*/
Evenement_Trainings_sessie__r.Aantal_inschrijvingen__c, /*num inscrições*/
/* Participant */
Deelnemer__r.Name,
Deelnemer__r.Email,
Deelnemer__r.Account.name,
/* Participantion */
Aanwezig_tijdens_sessie__c
FROM Deelnemer_Evenement_Training__c
WHERE Name = :participantIdSQL];
if(participantion.Aanwezig_tijdens_sessie__c == 'Ja')
{
alreadyAttending = true;
}
} catch (Exception e) {
participantion = null;
}
return null;
}
public pageReference Present()
{
participantion.Aanwezig_tijdens_sessie__c = 'Ja';
try{
update(participantion);
Updated = true;
} catch (Exception e) {
UpdateError = true;
}
return null;
}
public pageReference reset()
{
reset = false;
Updated = false;
alreadyAttending = false;
UpdateError = false;
participantId = '';
participantion = null;
return null;
}
}
"
we have had devlopment done for us, but not anymore, and i'm trying to change a VF page and controller to lookup a training participant based upon his/her email address.
What do i have to change to search on email instead of D-Number. can anyone help me out?
the controller i have now is:
"
public class TrainingController {
String searchText;
List<Deelnemer_Evenement_Training__c> results;
public String getSearchText() {
return searchText;
}
public void setSearchText(String s) {
searchText = s;
}
public List<Deelnemer_Evenement_Training__c> getResults() {
return results;
}
public PageReference doSearch() {
results = (List<Deelnemer_Evenement_Training__c>)[FIND :searchText RETURNING Deelnemer_Evenement_Training__c(First_name__c, Last_name__c, E_mail_deelnemer__c, Evenement_Trainings_sessie__c)][0];
return null;
}
public String participantId {get; set;}
public boolean reset {get; set;}
public boolean alreadyAttending {get; set;}
public boolean UpdateError {get; set;}
public boolean Updated {get; set;}
public Deelnemer_Evenement_Training__c participantion {get; set;}
public TrainingController(){
reset = false;
alreadyAttending = false;
Updated = false;
UpdateError = false;
participantId = '';
}
public pageReference getRegistration ()
{
reset = true;
Updated = false;
string participantIdSQL = 'D-'+participantId;
alreadyAttending = false;
participantion = new Deelnemer_Evenement_Training__c();
try{
participantion = [SELECT /*Event / Trainings session */
Evenement_Trainings_sessie__r.name,
Evenement_Trainings_sessie__r.Startdatum__c, /*start Date*/
Evenement_Trainings_sessie__r.Aantal_inschrijvingen__c, /*num inscrições*/
/* Participant */
Deelnemer__r.Name,
Deelnemer__r.Email,
Deelnemer__r.Account.name,
/* Participantion */
Aanwezig_tijdens_sessie__c
FROM Deelnemer_Evenement_Training__c
WHERE Name = :participantIdSQL];
if(participantion.Aanwezig_tijdens_sessie__c == 'Ja')
{
alreadyAttending = true;
}
} catch (Exception e) {
participantion = null;
}
return null;
}
public pageReference Present()
{
participantion.Aanwezig_tijdens_sessie__c = 'Ja';
try{
update(participantion);
Updated = true;
} catch (Exception e) {
UpdateError = true;
}
return null;
}
public pageReference reset()
{
reset = false;
Updated = false;
alreadyAttending = false;
UpdateError = false;
participantId = '';
participantion = null;
return null;
}
}
"
Below code should work for you provided "participantId" variable is getting email from your front end.
Thanks,
Sumit
{!participantion.Deelnemer__r.Name}
<apex:form >
<apex:image style="margin-left: 200px; margin-top: 40px; width: 150px;" url="https://www.twinfield.nl/wp-content/uploads/2015/01/Twinfield-logo-fc-2015-wit.png"/>
<div class="lookup">
Email address <br/>
<apex:inputText id="searchText" value="{!searchText}"/>
<apex:commandButton value="Go!" action="{!doSearch}"
rerender="block" status="status"/><br/>
<apex:commandButton styleClass="bt" value="Reset Participant" action="{!reset}"/>
<apex:commandButton status="margin-left: 20px;" styleClass="bt" value="LookUp Participant" action="{!getRegistration}"/><br/>
</div>
<div style="margin-left: auto; margin-right: auto; margin-top:100px; width: 450px;">
<apex:panelGrid rendered="{!ISNULL(participantion) && reset}">
No Participant found with the Number D-{!participantId}.
</apex:panelGrid>
<apex:panelGrid rendered="{!alreadyAttending}">
The participant D-{!participantId} is already attending the Event.
</apex:panelGrid>
<apex:panelGrid rendered="{!UpdateError}">
An Error Hapenend while updating the participant D-{!participantId} information, please check back on Salesfroce.<br/>
<apex:outputLink value="/{!participantion.id}">{!participantion.Deelnemer__r.Name}</apex:outputLink>
</apex:panelGrid>
<apex:panelGrid rendered="{!NOT(ISNULL(participantion))&& NOT(alreadyAttending)}">
<table>
<tr>
<th>Event:</th><td>{!participantion.Evenement_Trainings_sessie__r.name}</td>
</tr>
<tr>
<th>Participant:</th><td></td>
</tr>
<tr>
<td></td><th>Name:</th><td>{!participantion.Deelnemer__r.Name}</td>
</tr>
<tr>
<td></td><th>Email:</th><td>{!participantion.Deelnemer__r.Email}</td>
</tr>
<tr>
<td></td><th>Company:</th><td>{!participantion.Deelnemer__r.Account.name}</td>
</tr>
</table>
<apex:commandButton style="float: right;" styleClass="bt" value="Attending" action="{!Present}"/>
<apex:outputText rendered="{!Updated}">Participant D-{!participantId} is attending the {!participantion.Evenement_Trainings_sessie__r.name}.</apex:outputText>
</apex:panelGrid>
</div>
</apex:form>
</apex:page>
Thanks for helping so far!
<apex:form > <apex:image style="margin-left: 200px; margin-top: 40px;" url="http://www.twinfield.nl/wp-content/themes/twinfield/img/logo.png"/> <div class="lookup"> Participant Number (D-*****)<br/> D-<apex:inputText value="{!participantId}"/> <br/> <apex:commandButton styleClass="bt" value="Reset Participant" action="{!reset}"/> <apex:commandButton status="margin-left: 20px;" styleClass="bt" value="LookUp Participant" action="{!getRegistration}"/> </div> <div style="margin-left: auto; margin-right: auto; margin-top:100px; width: 450px;"> <apex:panelGrid rendered="{!ISNULL(participantion) && reset}"> No Participant found with the Number D-{!participantId}. </apex:panelGrid> <apex:panelGrid rendered="{!alreadyAttending}"> The participant D-{!participantId} is already attending the Event. </apex:panelGrid> <apex:panelGrid rendered="{!UpdateError}"> An Error Hapenend while updating the participant D-{!participantId} information, please check back on Salesfroce.<br/> <apex:outputLink value="/{!participantion.id}">{!participantion.Deelnemer__r.Name}</apex:outputLink> </apex:panelGrid> <apex:panelGrid rendered="{!NOT(ISNULL(participantion))&& NOT(alreadyAttending)}"> <table> <tr> <th>Event:</th><td>{!participantion.Evenement_Trainings_sessie__r.name}</td> </tr> <tr> <th>Participant:</th><td></td> </tr> <tr> <td></td><th>Name:</th><td>{!participantion.Deelnemer__r.Name}</td> </tr> <tr> <td></td><th>Email:</th><td>{!participantion.Deelnemer__r.Email}</td> </tr> <tr> <td></td><th>Company:</th><td>{!participantion.Deelnemer__r.Account.name}</td> </tr> </table> <apex:commandButton style="float: right;" styleClass="bt" value="Attending" action="{!Present}"/> <apex:outputText rendered="{!Updated}">Participant D-{!participantId} is attending the {!participantion.Evenement_Trainings_sessie__r.name}.</apex:outputText> </apex:panelGrid> </div> </apex:form> </apex:page>
<apex:page controller="EventRegistrationController" showHeader="false" sidebar="false" standardStylesheets="false"> <style> .lookup { text-align: center; margin-left: auto; margin-right: auto; margin-top: 32px; padding: 28px; line-height: 51px; font-size: 14px; font-family: arial; width: 450px; height: 152px; box-shadow: 0 0 10px #555; background: #fff; padding: 5px; border-radius: 4px; -moz-border-radius: 4px; -webkit-border-radius: 4px; } th { font-weight: bold; text-align: right; } .bt { border: 1px solid #eb7b34; display: inline-block; font-weight: bold; font-size: 13px; color: #fff; padding: 4px 20px; border-radius: 5px; -moz-border-radius: 5px; -webkit-border-radius: 5px; text-shadow: 1px 1px rgba(0,0,0,.3); background: #f2ae41; background: -moz-linear-gradient(top, #f2ae41 0%, #ef9a36 50%, #ed8a19 51%, #e97315 100%); background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#f2ae41), color-stop(50%,#ef9a36), color-stop(51%,#ed8a19), color-stop(100%,#e97315)); background: -webkit-linear-gradient(top, #f2ae41 0%,#ef9a36 50%,#ed8a19 51%,#e97315 100%); background: -o-linear-gradient(top, #f2ae41 0%,#ef9a36 50%,#ed8a19 51%,#e97315 100%); background: -ms-linear-gradient(top, #f2ae41 0%,#ef9a36 50%,#ed8a19 51%,#e97315 100%); background: linear-gradient(top, #f2ae41 0%,#ef9a36 50%,#ed8a19 51%,#e97315 100%); filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#f2ae41', endColorstr='#e97315',GradientType=0 ); } body { font: 20px Helmet, Freesans, sans-serif; font-aligment; center; color: #565656; background: url(http://www.twinfield.nl/wp-content/themes/twinfield/img/bg.png) repeat-x top center; } </style>