Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a custom entity which has a custom relationship 'User' back to the User table.
I can do

SELECT Id, User__r.Id from MyCustomEntity

However, I want to get a information about the user's manager.

I try:

SELECT Id, from MyCustomEntity

But I get:

Save error: Didn't understand relationship 'Manager__R' in field path

Is it possible to achieve want I want in SOQL or must I do this in memory programmatically via a separate statement?


share|improve this question
up vote 9 down vote accepted

Manager is a standard field. It should just be:

SELECT Id, User__r.Manager.Email FROM MyCustomEntity

For future reference, the User documentation

share|improve this answer

Determining the correct nomenclature for a relationship can be tricky depending on the object and relationship type. I find it easiest to create the API WSDL and look at the object fields. In the case of Manager field, the WSDL shows:

<element name="Manager" nillable="true" minOccurs="0" type="ens:User"/>

For comparison, a custom object relationship looks something like this:

<element name="Company_Users__r" nillable="true" minOccurs="0" type="tns:QueryResult"/>

Notice the __r in the later case.

(To create the WSDL, search for API in the setup menu and select Generate Enterprise WSDL.)

share|improve this answer
This isn't a bad idea, but for a Standard object like this it is usually much easier to just Google search the API documentation. They have this all already done in an easily readible format -… – Jesse Altman Feb 7 '13 at 14:11

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.