Take the 2-minute tour ×
Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. It's 100% free, no registration required.

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, User__R.Manager__R.email 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?

Thanks.

share|improve this question

2 Answers 2

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 - salesforce.com/us/developer/docs/api/Content/… –  Jesse Altman Feb 7 '13 at 14:11

Your Answer

 
discard

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.