Development questions

Write a SOQL query to fetch Tasks where the WhoId (Polymorphic lookup) points only to a Lead and not a Contact (WHERE Who.Type = 'Lead').

DevelopmentMediumSalesforceDeloitteSlalom

WhoId is polymorphic (Lead or Contact). Filter on the related type with Who.Type.

soql
SELECT Id, Subject, WhoId, Who.Name FROM Task WHERE Who.Type = 'Lead'

This returns only Tasks whose Who is a Lead and excludes those pointing to Contacts.

soqlscenariopolymorphic