+ Start a Discussion
sobjectsobject 

How to differentiate activity history record type?

I want to create an SOQL query returning all Contacts that have ActivityHistory.  If I do this:

SELECT Id, Name, (SELECT CallType,ActivityDate,Subject FROM ActivityHistories) FROM Contact

...then I get ALL Contacts regardless of whether they have ActivityHistories or not.

So then I tried:

SELECT Id, Name,
    (SELECT CallType,ActivityDate,Subject
     FROM ActivityHistories where ActivityDate != null and Id != null) FROM Contact
    
...and STILL I get back Contacts without ActivityHistories.  Does anyone know how to formulate
a query that returns all Contacts and only Contacts which have ActivityHistories?