Don't have an account?
Search for an answer or ask a question of the zone or Customer Support.
You need to sign in to do that
Sign in to start searching questions
Signup for a Developer Edition
Sign in to start a discussion
Can you share the code as content not as screenshot as it would be diffiuclt to check the code if shared as screenshot.
Please add the code as comment and also if possible can you add the exact requirement and vfpage for the same.
Thanks,
public class AccountController {
Public String AccName{set;get;}
Public String AccNumber{set;get;}
Public String AccRating{set;get;}
Public String AccPhone{set;get;}
Public PageReference SaveAccount(){
Account Acc = New Account();
Acc.Name = AccName;
Acc.phone = AccPhone;
Acc.Rating = AccRating;
Acc.AccountNumber = AccNumber;
PageReference pageRef;
If(Acc.Name == null || Acc.Name ==''){
ApexPages.Message myMsg =New ApexPages.Message(ApexPages.Severity.ERROR, 'Account Name is Mandatory');
ApexPages.addMessage(myMsg);
}else{
insert acc;
pageRef = new PageReference('/'+acc.Id);
pageRef.setRedirect(True);
}
return pageRef;
}
}
I tried to save the above mentioned class and did not face any errors while saving it.
I hope Earlier you did not define Account acc in the method I guess which caused the issue.
Let me know if you face any issues.
If this solution helps, Please mark it as best answer.
Thanks,