I have below query fetching contact fields and task fields from task object

SELECT Id,Who.Name, Subject,Description, ActivityDate, Status, OwnerId, CreatedBy.Name, 
                         CreatedDate,LastModifiedById FROM Task

but when I change who.name to any who.CustomFieldFromContact__c object, I get an error

CustomFieldFromContact__c is a date field

can someone please suggest how to fetch custom contact fields from task object?

1 Answer 1


Unfortunately there isn't any way to do this.

The Who field is a polymorphic relationship that can point to either a Contact or User. Because of this, traversing the relationship via the dot notation isn't currently possible.

Similar questions with similar answers: How do i specify a formula field in task to display mobile

Essentially you'll need to query your tasks, create a list of who ids, then separately query the Contact table and join them together in your own code.

  • Isn't the Who, a Lead or a Contact? In contract to a User or Contact?
    – m0c
    Commented Aug 5, 2019 at 11:15

You must log in to answer this question.

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