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
eddieeddie 

Is there a trick to getting parent joins on Task using the WhatId relationship to work?

If I execute this query:

SELECT a.Id, a.WhoId, a.WhatId, a.Subject, b.Website, b.Id FROM Task a, a.What b

I get the following error:

INVALID_FIELD:

a.ReminderDateTime, a.IsReminderSet, b.Website, b.Id FROM Task a, a.What

                                     ^

ERROR at Row:1:Column:342

No such column 'Website' 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.

 

The problem seems to be that SOQL can't figure out what to do because the a.What relationship points to a number on entities. Is there some trick I need to do to get this to work?

 

Thanks,

 

Eddie

 
SuperfellSuperfell
As explained in the soql docs, relationships that are polymorphic (point to more than one type) resolve down to the name entity which has a small subset of fields on it, you can't query type specific fields that way. You'll have to do 2 queries. (or a query and retrieve depending on if your in apex or the api)