I am writing a callout=true function that will be calling an external service with some data collected from Salesforce. Since callout functions can't receive complex objects as arguments, and I have to pass through data from Case, Account and Contact objects related to the case, I wanted to save some SOQL limits and extract the Contact.Email field from the Case SOQL query (as referenced here, for example).

However when I went ahead to test this, here is what I get:

Case[] a = [SELECT Contact.Email FROM Case WHERE CaseNumber = '00007278'];


|USER_DEBUG|[2]|DEBUG|(Case:{ContactId=003R000001Vt6e1IAB, Id=500R000000CR30UIAT})

The contact definitely does have an email address, so that's not the problem. Is this something that is no longer possible? Will I have to make a separate query for this? This is a very strange behavior, because I assumed that if I can't get contact.email from the query the query would error out instead of returning the Id of the object.

1 Answer 1


Apparently I misunderstood the way this query works, and this was an educational experience of sorts. Whene you query for Contact.Email in a Case query, it basically returns a Contact object in the query, which contains the requested data. If the code snippet above is changed to

Case[] a = [SELECT Contact.Email FROM Case WHERE CaseNumber = '00007278'];

The output becomes:

14:45:02.35 (49806870)|USER_DEBUG|[2]|DEBUG|Contact:{Id=003R000001Vt6e1IAB, Email=testgurl@redacted}```

You must log in to answer this question.

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