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
Esther MercEsther Merc 

visualforce Error: RegistrationController Compile Error: Unexpected token ','. at line 25 column 65

Hi Guys , 
 After filling Registration form when Submit is clicked should be take to Welcome Page  and Information in Form should be saved to Registration__c  that I created

But got this Error
Error: RegistrationController Compile Error: Unexpected token ','. at line 25 column 65

Visualforce Page
apex:page controller = "RegistrationController">
 <apex:sectionHeader  title = "Registration Form" />
  <apex:form>
 
   <apex:pageBlock>
   <apex:pageBlockButtons location="bottom" >
     <apex:commandButton value="Submit"  action="{!WelcomePage}"/>
       
   </apex:pageBlockButtons>
   
   <apex:pageBlockSection>  collapsible = "false" columns="1">
      <apex:pageMessages>     </apex:pageMessages>
      <apex:inputText label="Name" value="{!reg.Name}" />
      <apex:inputText label="Username"  />
      <apex:inputSecret label="Password"   />
      <apex:inputSecret label="Confirm Password"   />
       <apex:inputText label="SecurityQuestion"    size="1">  />
        
         <apex:selectOptions>  
         value="{!SecurityQuestion}">
         </apex:selectOptions>
        
         </selectList>
         <apex:inputText label="Answer"/>
      
   
   
   </apex:pageBlockSection>
  </apex:pageblock>
 </apex:form>
 </apex:page>
 


Controller Class
ublic class RegistrationController {

Public pageReference  RedirectToLoginPage() {
     return null;
 }
 
 Public RegistrationController() {
       reg = new Registration__c();
       
 }
 
 public Registrationcontroller(ApexPages.StandardController controller) {
 
}


Public PageReference  RedirectToFinalPage() {
   pageReference  pg = new pageReference ('/apex/WelcomePage');
   return pg.setRedirect(true);
}
 
     
public pageReference   welcomePage(){
   if (string.isBlank (reg.Name__c)) {
       ApexPages.addMessage(new ApexPages.Message.severity.ERROR,'Enter Username!!'));
        return null;
     }
     
     insert reg;
       pageReference  pg = new pageReference ('/apex/WelcomePage');
   return pg.setRedirect(true);
   
 }


public pageReference loginPage(){
  pageReference  pg = new pageReference ('/apex/LogingPage');
   return pg.setRedirect(true);
 }
 
 public pageReference SignupPage() {
 
 
 pageReference pg = new pageReference ('/apex/LogingPage');
  return pg.setRedirect(true);

}


Public pageReference   resetPassword(){
    pageReference  pg = new pageReference ('/apex/ResetPasswordPage');
    return pg.setRedirect(true);
 }

Public Registration__c   reg {get;set;}

Public List<schema.PicklistEntry>
 getSecurityList= Registration__c.Security_Question__c.getDescribe().getPicklistValues();
       for(schema.PicklistEntry  securityQn : getSecurityList) {
           listSecurityQuestions.add(new  SelectOption(securityQn.getLabel()));

}
   Return listSecurityQuestions;

}

 Public  void  sendEmail() {
   Messaging.SingleEmailMessage eMailObj = new Messaging.SingleEmailMessage();

String[] ToAddress = new String []  {'esther@gmail.com '};
eMailObject.setToAddresses(ToAddress);

String subject = 'New Password';
eMailObject.setSubject(subject);
String mailBody = '<b> New Password was created <b>';

eMailObject.setHtmlBody(mailBody);

Messaging.sendEmail( new Messaging.SingleEmailMessage[]eMailObj});

   }

}
Best Answer chosen by Esther Merc
Sai PraveenSai Praveen (Salesforce Developers) 
Hi,

Can you rewrite the last method as below.
 
Public  void  sendEmail() {
   Messaging.SingleEmailMessage eMailObj = new Messaging.SingleEmailMessage();

String[] ToAddress = new String []  {'esther@gmail.com '};
eMailObj.setToAddresses(ToAddress);

String subject = 'New Password';
eMailObj.setSubject(subject);
String mailBody = '<b> New Password was created <b>';

eMailObj.setHtmlBody(mailBody);
Messaging.SingleEmailMessage[] messages = new List<Messaging.SingleEmailMessage> {eMailObj};
         Messaging.SendEmailResult[] results = Messaging.sendEmail(messages);


   }


Let me know if any error on it.

The total class looks as below.
 
public class RegistrationController {

Public pageReference  RedirectToLoginPage() {
     return null;
 }
 
 Public RegistrationController() {
       reg = new Registration__c();
       
 }
 
 public Registrationcontroller(ApexPages.StandardController controller) {
 
}


Public PageReference  RedirectToFinalPage() {
   pageReference  pg = new pageReference ('/apex/WelcomePage');
   return pg.setRedirect(true);
}
 
     
public pageReference   welcomePage(){
   if (string.isBlank (reg.Name__c)) {
       ApexPages.addMessage(new ApexPages.Message(Apexpages.Severity.ERROR,'Enter Username!!'));
        return null;
     }
     
     insert reg;
       pageReference  pg = new pageReference ('/apex/WelcomePage');
   return pg.setRedirect(true);
   
 }


public pageReference loginPage(){
  pageReference  pg = new pageReference ('/apex/LogingPage');
   return pg.setRedirect(true);
 }
 
 public pageReference SignupPage() {
 
 
 pageReference pg = new pageReference ('/apex/LogingPage');
  return pg.setRedirect(true);

}


Public pageReference   resetPassword(){
    pageReference  pg = new pageReference ('/apex/ResetPasswordPage');
    return pg.setRedirect(true);
 }

Public Registration__c   reg {get;set;}

Public List<schema.PicklistEntry>
 getSecurityList= Registration__c.Security_Question__c.getDescribe().getPicklistValues();
    {
    for(schema.PicklistEntry securityQn:getSecurityList) {
        listSecurityQuestions.add(new  SelectOption(securityQn.getValue(), securityQn.getLabel()));

Return listSecurityQuestions;

}
   
}


 Public  void  sendEmail() {
   Messaging.SingleEmailMessage eMailObj = new Messaging.SingleEmailMessage();

String[] ToAddress = new String []  {'esther@gmail.com '};
eMailObj.setToAddresses(ToAddress);

String subject = 'New Password';
eMailObj.setSubject(subject);
String mailBody = '<b> New Password was created <b>';

eMailObj.setHtmlBody(mailBody);
Messaging.SingleEmailMessage[] messages = new List<Messaging.SingleEmailMessage> {eMailObj};
         Messaging.SendEmailResult[] results = Messaging.sendEmail(messages);


   }

}

If this solution help, Please mark it as best answer.

Thanks,
 

All Answers

Sai PraveenSai Praveen (Salesforce Developers) 
Hi ,

There was an extra ) at the end of 25th line which caused the issue. 
 
ApexPages.addMessage(new ApexPages.Message.severity.ERROR,'Enter Username!!');

Can you check saving it as above .

Let me know if you need any help on it.


If this solution helps, Please mark it as best answer.

Thanks,
 
Esther MercEsther Merc
Thanks Sai for quick response, Below is how I fixed it but it showing this Error now.  Everytime I fix something I'm getting a different error elsewhere.



Error: RegistrationController Compile Error: Missing '<EOF>' at 'for' at line 60 column 3


Controller Class

public class RegistrationController {

Public pageReference  RedirectToLoginPage() {
     return null;
 }
 
 Public RegistrationController() {
       reg = new Registration__c();
       
 }
 
 public Registrationcontroller(ApexPages.StandardController controller) {
 
}


Public PageReference  RedirectToFinalPage() {
   pageReference  pg = new pageReference ('/apex/WelcomePage');
   return pg.setRedirect(true);
}
 
     
public pageReference   welcomePage(){
   if (string.isBlank (reg.Name__c)) {
       ApexPages.addMessage(new ApexPages.Message(Apexpages.Severity.ERROR,'Enter Username!!'));
        return null;
     }
     
     insert reg;
       pageReference  pg = new pageReference ('/apex/WelcomePage');
   return pg.setRedirect(true);
   
 }


public pageReference loginPage(){
  pageReference  pg = new pageReference ('/apex/LogingPage');
   return pg.setRedirect(true);
 }
 
 public pageReference SignupPage() {
 
 
 pageReference pg = new pageReference ('/apex/LogingPage');
  return pg.setRedirect(true);

}


Public pageReference   resetPassword(){
    pageReference  pg = new pageReference ('/apex/ResetPasswordPage');
    return pg.setRedirect(true);
 }

Public Registration__c   reg {get;set;}

Public List<schema.PicklistEntry>
 getSecurityList= Registration__c.Security_Question__c.getDescribe().getPicklistValues();
 }
    for(schema.PicklistEntry securityQn:getSecurityList) {
        listSecurityQuestions.add(new  SelectOption(securityQn.getValue(), securityQn.getLabel()));

Return listSecurityQuestions;

}
   
}


 Public  void  sendEmail() {
   Messaging.SingleEmailMessage eMailObj = new Messaging.SingleEmailMessage();

String[] ToAddress = new String []  {'esther@gmail.com '};
eMailObject.setToAddresses(ToAddress);

String subject = 'New Password';
eMailObject.setSubject(subject);
String mailBody = '<b> New Password was created <b>';

eMailObject.setHtmlBody(mailBody);

Messaging.sendEmail( new Messaging.SingleEmailMessage[]eMailObj});


   }

}

 
Sai PraveenSai Praveen (Salesforce Developers) 
Hi Esther,

Can you check the below code and let me know if you are facing issues.
 
public class RegistrationController {

    Public pageReference  RedirectToLoginPage() {
         return null;
     }
     
     Public RegistrationController() {
           reg = new Registration__c();
           
     }
     
     public Registrationcontroller(ApexPages.StandardController controller) {
     
    }
    
    
    Public PageReference  RedirectToFinalPage() {
       pageReference  pg = new pageReference ('/apex/WelcomePage');
       return pg.setRedirect(true);
    }
     
         
    public pageReference   welcomePage(){
       if (string.isBlank (reg.Name__c)) {
           ApexPages.addMessage(new ApexPages.Message(Apexpages.Severity.ERROR,'Enter Username!!'));
            return null;
         }
         
         insert reg;
           pageReference  pg = new pageReference ('/apex/WelcomePage');
       return pg.setRedirect(true);
       
     }
    
    
    public pageReference loginPage(){
      pageReference  pg = new pageReference ('/apex/LogingPage');
       return pg.setRedirect(true);
     }
     
     public pageReference SignupPage() {
     
     
     pageReference pg = new pageReference ('/apex/LogingPage');
      return pg.setRedirect(true);
    
    }
    
    
    Public pageReference   resetPassword(){
        pageReference  pg = new pageReference ('/apex/ResetPasswordPage');
        return pg.setRedirect(true);
     }
    
    Public Registration__c   reg {get;set;}
    
    Public List<schema.PicklistEntry>
     getSecurityList= Registration__c.Security_Question__c.getDescribe().getPicklistValues();
     {
        for(schema.PicklistEntry securityQn:getSecurityList) {
            listSecurityQuestions.add(new  SelectOption(securityQn.getValue(), securityQn.getLabel()));
    
    Return listSecurityQuestions;
    
    }
       
    }
    
    
     Public  void  sendEmail() {
       Messaging.SingleEmailMessage eMailObj = new Messaging.SingleEmailMessage();
    
    String[] ToAddress = new String []  {'esther@gmail.com '};
    eMailObject.setToAddresses(ToAddress);
    
    String subject = 'New Password';
    eMailObject.setSubject(subject);
    String mailBody = '<b> New Password was created <b>';
    
    eMailObject.setHtmlBody(mailBody);
    
    Messaging.sendEmail( new Messaging.SingleEmailMessage[]eMailObj);
    
    
       }
    
    }

Thanks,
 
Esther MercEsther Merc
yes Sai I got this  Error Below

Error: RegistrationController Compile Error: Missing '{' at 'eMailObj' at line 82 column 60
Sai PraveenSai Praveen (Salesforce Developers) 
Hi,

Can you rewrite the last method as below.
 
Public  void  sendEmail() {
   Messaging.SingleEmailMessage eMailObj = new Messaging.SingleEmailMessage();

String[] ToAddress = new String []  {'esther@gmail.com '};
eMailObj.setToAddresses(ToAddress);

String subject = 'New Password';
eMailObj.setSubject(subject);
String mailBody = '<b> New Password was created <b>';

eMailObj.setHtmlBody(mailBody);
Messaging.SingleEmailMessage[] messages = new List<Messaging.SingleEmailMessage> {eMailObj};
         Messaging.SendEmailResult[] results = Messaging.sendEmail(messages);


   }


Let me know if any error on it.

The total class looks as below.
 
public class RegistrationController {

Public pageReference  RedirectToLoginPage() {
     return null;
 }
 
 Public RegistrationController() {
       reg = new Registration__c();
       
 }
 
 public Registrationcontroller(ApexPages.StandardController controller) {
 
}


Public PageReference  RedirectToFinalPage() {
   pageReference  pg = new pageReference ('/apex/WelcomePage');
   return pg.setRedirect(true);
}
 
     
public pageReference   welcomePage(){
   if (string.isBlank (reg.Name__c)) {
       ApexPages.addMessage(new ApexPages.Message(Apexpages.Severity.ERROR,'Enter Username!!'));
        return null;
     }
     
     insert reg;
       pageReference  pg = new pageReference ('/apex/WelcomePage');
   return pg.setRedirect(true);
   
 }


public pageReference loginPage(){
  pageReference  pg = new pageReference ('/apex/LogingPage');
   return pg.setRedirect(true);
 }
 
 public pageReference SignupPage() {
 
 
 pageReference pg = new pageReference ('/apex/LogingPage');
  return pg.setRedirect(true);

}


Public pageReference   resetPassword(){
    pageReference  pg = new pageReference ('/apex/ResetPasswordPage');
    return pg.setRedirect(true);
 }

Public Registration__c   reg {get;set;}

Public List<schema.PicklistEntry>
 getSecurityList= Registration__c.Security_Question__c.getDescribe().getPicklistValues();
    {
    for(schema.PicklistEntry securityQn:getSecurityList) {
        listSecurityQuestions.add(new  SelectOption(securityQn.getValue(), securityQn.getLabel()));

Return listSecurityQuestions;

}
   
}


 Public  void  sendEmail() {
   Messaging.SingleEmailMessage eMailObj = new Messaging.SingleEmailMessage();

String[] ToAddress = new String []  {'esther@gmail.com '};
eMailObj.setToAddresses(ToAddress);

String subject = 'New Password';
eMailObj.setSubject(subject);
String mailBody = '<b> New Password was created <b>';

eMailObj.setHtmlBody(mailBody);
Messaging.SingleEmailMessage[] messages = new List<Messaging.SingleEmailMessage> {eMailObj};
         Messaging.SendEmailResult[] results = Messaging.sendEmail(messages);


   }

}

If this solution help, Please mark it as best answer.

Thanks,
 
This was selected as the best answer
Esther MercEsther Merc
Thank you so much for helping, Im getting this error now ,, can you just help me on this one I think all else should be fine 

Error: RegistrationController Compile Error: Variable does not exist: listSecurityQuestions at line 61 column 9