I have created a lookup relationship from case to Opportunity and my aim is to extract the email of the opportunity owner and store it in a field on 'Case' but the query doesn't seem to go right.

Here is the query;

Select Id, status, Opportunity__r.Owner.email, Opportunity__r.Id, Opportunity__r.IsClosed from Case Where Status = 'Closed Won' OR Status = 'Closed Lost'

  • FYI - Opportunity owner field is a lookup to User object.
    – SfdcBat
    Commented Nov 9, 2017 at 15:22

1 Answer 1


If you execute the query from query editor you will see result like below:

enter image description here

Try using execute anonymous window to query the result and store it in a variable. Check the owner email and you should able to get it:

Case o =[select id,opportunity__r.Name,Opportunity__r.Owner.email from case where id='5003700000CRFeR'];

Outputs -> [email protected]

You must log in to answer this question.

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