0

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

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 Aug 5 '19 at 11:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.