function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ 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: