I'm pretty new to SalesForce and my question should be very simple.
I'm creating an extension for a standard controller of a custom object called Bill_Account_c. This object has a master detail field with another custom object called Bill_c.
In the constructor, I want to get the Bill__c associated to the Bill_Account__c.
Here's what I've tried in apex:
public newConstructor(ApexPages.StandardController standardController) {
controller = standardController;
billAccount = (Bill_Account__c)controller.getRecord();
Bill__c bill = [SELECT Id, Bill_Field1__c, Bill_Field2__c FROM Bill__c WHERE Id = :billAccount.Bill__c];
}
but I get this error:
SObject row was retrieved via SOQL without querying the requested field: Bill_Account__c.Bill__c
What am I doing wrong? Sorry if this is a silly question.