0

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 Nov 9 '17 at 15:22
0

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'];
system.debug(o.Opportunity__r.Owner.email);

Outputs -> myemailid@gmail.com

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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