I have a controller with a constructor. Where i'm querying lead record with an id. When i'm trying to reference a field from this sObject I get "Variable does not exist: Email"
public Lead_Controller {
public sObject leadrecord {get;set;}
public Lead_Controller(ApexPages.StandardController controller){
string leadrecordId = controller.getRecord().id;
leadrecord = [select id, name, Email from Lead where Id =:leadrecordId];
if(leadrec.Email != null){
//trying get the email here and got "Variable does not exist: Email"
}
}
}
any ideas? why would this happen?