function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion

Relationship Query Question

I'm having trouble retrieving values from multiple SObjects.

I have a Custom Object which has a Master-Detail relationship to Account.  Call it Object1.  I need to retrieve values from the Account which are lookup fields to the User Object.


Select account__r.Name, account__r.Account_Manager From Object  >this returns the account name and the userId of the Account Manager


I need to retrieve the Account Manager's name and e-mail

Select account__r.Account_Manager.Name, from Object1  > doesn't return anything.


I can retrieve the userId for the Account_Manager, but how do I then access the User fields for that Id?




The name field and the email field of the user object is not queryable

The fields can be queried through __r (for custom relationships) or through the "id-less" version of the field (for standard relationships). So: or or

Hope this helps.

Thanks - that query runs, but  the name and email values are always blank. If I run with Limit 10

I get back 10 user rows with no values.   If I run the query with select from Account instead of from object1 it works.


From account    - this works



From Object1   - this returns blank user rows


1) Make sure account_manager__c is not blank on the account you're querying; if so, it would indeed be null/blank.

2) System.debug(object1) won't show it, but System.debug( will.

3) You are limited to four relationships away upstream (e.g. (but this doesn't seem to be a problem here).




Thanks for the sanity check. I'm going to try a different lookup field with the same query syntax.