You need to sign in to do that
Don't have an account?
shill
SOQL Relationship Query Error
Hello,
I am trying to write a Salesforce Object Query that retrieves data from the Task entity, but also pulls lead/contact information based on the "WhoId" field.
If I run the following query, I have no problem getting a result set:
Select Id,Who.FirstName,Who.LastName From Task
If I add the "Email" field to the select list, I get an error:
Select Id,Who.Email,Who.FirstName,Who.LastName From Task
INVALID_FIELD:
Select Id,Who.Email,Who.FirstName,Who.LastName
^
ERROR at Row:1:Column:11
No such column 'Email' on entity 'Name'. If you are attempting to use a custom field, be sure to append the '__c' after the custom field name. Please reference your WSDL or the describe call for the appropriate names.
Select Id,Who.Email,Who.FirstName,Who.LastName
^
ERROR at Row:1:Column:11
No such column 'Email' on entity 'Name'. If you are attempting to use a custom field, be sure to append the '__c' after the custom field name. Please reference your WSDL or the describe call for the appropriate names.
Is the email field not supported in this kind of a query, or am I doing something wrong.
Any help would be greatly appreciated.
Thank you,
Scott
Superfell
Because the who relationship is polymorphic, there's only a very limited subset of fields available when the relationship is queried via SOQL-R, and email isn't one of them. You'll have to break it up into multiple queries.
shill
Thank you for the quick reply Simon!
Is there documentation I can take a look at that would tell me what fields are inlcuded in something like this (or perhaps which fields aren't?)
Thank you,
Scott
Superfell
IIRC, there's a section on polymorphic relationships in the API docs.