There is a feature in the works that allows you to query this data. It is currently a preview feature and can't be used in production code (yet). You can see the documentation for TYPEOF. Without TYPEOF, you have to perform two queries; one to obtain the tasks, and another to grab the contact or lead. Conversely, you could use a sub-query to query from lead or contact and their tasks.
TYPEOFSELECT Id, Subject, ActivityDate, WhatId, Description, TYPEOF WhoId WHEN Contact THEN Position__c END FROM Task WHERE WhoId = :application.Candidate_Contact__cSub-querySELECT Id,Name,Position__c,(SELECT Id, Subject, Activitydate, WhatId, Description FROM Task
You can refer to this post:
http://salesforce.stackexchange.com/questions/17630/polymorphic-lookups-how-to-pull-the
Thanks,
Pratik
TYPEOFSELECT Id, Subject, ActivityDate, WhatId, Description, TYPEOF WhoId WHEN Contact THEN Position__c END FROM Task WHERE WhoId = :application.Candidate_Contact__cSub-querySELECT Id,Name,Position__c,(SELECT Id, Subject, Activitydate, WhatId, Description FROM Task