+ Start a Discussion
Oldwen AdrianoOldwen Adriano 

Simple relational query not working

Hello... I am trying to write a simple query which uses 2 tables that are related via the WhoID.  Can someone please help me understand why this won't work??

Didn't understand relationship 'Contact' in field path

Select ID, Subject, ActivityDate, Due_Time__c, Description, Contact.Phone from Task

The Contact object has a related field Task using the WhoID

User-added image
Jason Curtis NBSFDGJason Curtis NBSFDG
Doing SOQL against the Task object can be funky since it is polymorphic (attached to Lead or Contact).
This gets the name from the contact (or lead):
Select ID, Subject, ActivityDate, Description, Who.Name
From Task
But, as far as I can tell you can't get the phone this way (i.e. Who.Phone doesn't pull any data). You can see some other notes here:
http://stackoverflow.com/questions/14692742/how-to-get-email-from-task-object-record-using-soql