+ Start a Discussion

what is polymorphic lookup in salesforce? what is the advantage of this?

PratikPratik (Salesforce Developers) 
Hi Sultan

You can refer to this post:

Sagar PareekSagar Pareek
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
Justin J. YueJustin J. Yue
You might look at the post: http://wp.me/p19Otf-2Q