You need to sign in to do that
Don't have an account?
APEX controller how to query for relationship fields
Hi,
I've created a custom page that queries an account and its opened cases. For that page I've created an apex controller that queries for the account based on one of the account's fields.
Until now everything works fine, the query is a very simple one:
List <Account> account = [select field1_c field2_c etc from Account where field1_c = :'ggggg'];
List<Case> cases = [select field1_c field2_c etc from Case where field1_c = :'ggggg'];
Now I would like to also have access to a relationship field and I would like to know how to query it.
The field I'm trying to show in that page is:
Account.Parent.Parent.Account_Manager__r.FirstName
How should I write the select in order to query for this type of field?
They appear as default when I create a page with a standard controller referencing the account object.
Thanks
Tzuvy
[SELECT Parent.Parent.Account_Manager__r.FirstName FROM Account]