function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Mike445Mike445 

Query for contact email from case

HI,

I am trying to write an soql query on Case object. I am looking for contact email. How do i query for it?

 

I tried the below query and it gave an error.

 

 

Select Contact.id.Email from Case where Id=: c.id;

 

Any help is appreciated.

 

*c.id is case Id.

 

 

Thanks,

Mike

Best Answer chosen by Admin (Salesforce Developers) 
ryanjuptonryanjupton

The SOQL is pretty straight forward. You dont need the id part of contact.id.email. Just use this simple query.

 

SELECT contact.Email from Case

Actually using it to do what you're asking could look like this:

Case myCase = [select contact.email from case where id=: c.id][0];
String email = myCase.contact.email;

Feel free to clarify if I've misunderstood your question.

All Answers

ryanjuptonryanjupton

The SOQL is pretty straight forward. You dont need the id part of contact.id.email. Just use this simple query.

 

SELECT contact.Email from Case

Actually using it to do what you're asking could look like this:

Case myCase = [select contact.email from case where id=: c.id][0];
String email = myCase.contact.email;

Feel free to clarify if I've misunderstood your question.

This was selected as the best answer
Mike445Mike445

Thanks for the reply and you got me exactly right.