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
marchandojmarchandoj 

SOQL Query on Campaign Members and their related leads

I'm trying to write an SOQL query which will return the list of campaign members that have a create date the same as their related lead.

This is what I have written but the CreatedDate = Lead.CreatedDate condition is not working for me.

Can anyone help me?

 

SELECT Id, CreatedById, CreatedDate,LeadId, Lead.LeadSource, Campaign.Type
FROM CampaignMember cm WHERE cm.CreatedDate = Lead.CreatedDate AND cm.CreatedById NOT IN ('00520000001dRbb', '00520000001d89w')

digamber.prasaddigamber.prasad

cm.CreatedDate = Lead.CreatedDate is not valid in SOQL. You have to find other way, and I support, what you are trying to achieve is not possible in a single query.

 

Regards,

Digamber Prasad