0

I am trying to write a SOQL query that will return Opportunity information and also get fields from the User Object where the User is the Opportunity Owner. I am trying to pull in the user's profile photo URL.

The below SOQL does not work, but I am showing it to illustrate what I hope to do.

SELECT Id, Name, StageName, CloseDate, Owner.Id (SELECT FullPhotoUrl FROM User)
FROM Opportunity

How can I modify or write the SOQL query to return Opportunity information and fields from the User object who owns the Opportunity?

1 Answer 1

3

An owner is a parent object of opportunity so you want to access child-to-parent relationship using dot notation. Here is a query that would work:

SELECT Id, Name, StageName, CloseDate, Owner.FullPhotoUrl FROM Opportunity

you can read more about it here: Understanding Relationship Names, Custom Objects, and Custom Fields

You must log in to answer this question.

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