You need to sign in to do that
Don't have an account?
Error: Compile Error: line 43:0 no viable alternative at character ' ' at line 43 column 0
public class MeritusSignupController { public Form__c form {get;set;} public String formId {get;set;} public Account a {get;set;} public Contact c {get;set;} public String is_new {get;set;} public MeritusSignupController() { form= new Form__c(); form.Applicant_First_Name__c = UserInfo.getFirstName(); form.Applicant_Last_Name__c = UserInfo.getLastName(); form.Email__c = UserInfo.getUserEmail(); a= new account(); is_new = ApexPages.CurrentPage().getParameters().get('newform'); formId = ApexPages.CurrentPage().getParameters().get('formid'); String userId= UserInfo.getUserId(); c= new contact(); List<Form__c> formList = new List<form__c>(); if (is_new == 'true') { form = new form__c(); form.Applicant_First_Name__c = UserInfo.getFirstName(); form.Applicant_Last_Name__c = UserInfo.getLastName(); form.Email__c = UserInfo.getUserEmail(); } else if (formId != null) { formList = [Select id, Student__r.Name, Student__c, Applicant_First_Name__c,Applicant_Last_Name__c,Email__c from form__c where id =: formid]; } } void savefunc() { Boolean flag = false; if (form.Applicant_First_Name__c == null) { form.Applicant_First_Name__c.addError('Required field.'); flag = true; } } if (flag == false) { c.FirstName = form.Applicant_First_Name__c; c.LastName= form.Applicant_Last_Name__c; upsert form; upsert c; } }
As a common practice, if your question is answered, please choose 1 best answer.
But you can give every answer a thumb up if that answer is helpful to you.
Thanks
All Answers
The error is because the below code is being used outside the scope of the savefunc method:
if (flag == false)
{
c.FirstName = form.Applicant_First_Name__c;
c.LastName= form.Applicant_Last_Name__c;
upsert form;
upsert c;
}
Reason: Boolean flag is defined inside the function and the if loop is outside it.
Please let me know if this helps.
If yes, please mark the question as Solved.
Thanks and Regards,
Anirudh Singh
I've tried adding the IF statement inside of the fucntion and the error persists:
As a common practice, if your question is answered, please choose 1 best answer.
But you can give every answer a thumb up if that answer is helpful to you.
Thanks
Thx