Question
Why I can't access to opportunity account name on apex/vf ?
Backgound
I'm creating a opportunity VF page, extending the standarcontroller:
<apex:page standardController="Opportunity" extensions="test1Extension">
On my extension class I'm setting the opp object using:
opp = (Opportunity) controller.getRecord();
When I try to reference account on the vf by {!opp.Account.Name}
I get this error:
SObject row was retrieved via SOQL without querying the requested field: Opportunity.Account
In addition, I've tried to query the account using a subquery:
opp =[select Id, (select Id from Account where Id= opportunity.AccountId) from Opportunity where id=:opp.Id];
Or Account acc = [select Id from Account where id=:opp.AccountId];
SObject row was retrieved via SOQL without querying the requested field: Opportunity.AccountId
Summarizing
1) Why I can't reference Account from Opportunity ? 2) What is the proper why to make that sub-query?
thx in advance