2

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?

gs650x
  • 2,660
  • 11
  • 61
  • 101

1 Answers1

3

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.

Nick C
  • 6,565
  • 1
  • 29
  • 57