My company has four objects:

  1. Opportunity
  2. User
  3. Project
  4. Request

The Request object is a child of Project, which is itself a child of Opportunity. (Opportunity > Project > Request). Each opportunity has an owner.

How can I get the owner's name in an SOQL query along with information about the request?

The below request works, but gives me only the owner's ID.

SELECT Request__c.Id, Request__c.Name, Opportunity__R.OwnerId FROM Request__c WHERE Request__c.Id='123'

If I try to add a nested query like (SELECT Id FROM Opportunity__r.OwnerId) or (SELECT Id FROM User__r), I get the respective errors:

First SObject of a nested query must be a child of its outer query

Didn't understand relationship 'User__r' in FROM part of query call. If you are attempting to use a custom relationship, be sure to append the '__r' after the custom relationship name. Please reference your WSDL or the describe call for the appropriate names.

1 Answer 1


Use this Owner.Name

SELECT Request__c.Id, Request__c.Name, Opportunity__R.Owner.Name, Owner.Name
FROM Request__c 
WHERE Request__c.Id='123'
  • Owner.Name can't be a standalone field (it errors), but otherwise this works. Thanks.
    – Diego
    May 14, 2018 at 7:46

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .