0

Query

Select id,name,phone,email,CampaignMember 
from lead 
where CampaignMember=:selectedcampaign

Error

No such column 'CampaignMember' on entity 'Lead'. If you are attempting to use a custom field, be sure to append the '__c' after the custom field name. Please reference your WSDL or the describe call for the appropriate names.

Please help me to modify this.

  • here "selectedcampaign" is campaign id – SFDC V Apr 8 at 11:08
  • What is the condition that you are trying to form here and fetch the lead records? – Jayant Das Apr 8 at 13:27
0

You can use select Id, Name, Phone, Email from Lead where Id in (select LeadId from CampaignMember where CampaignId = :selectedcampaign)

0

If you want to get lead details which is part of a campaign then you will have to query CampaignMember records first where LeadId is matching and then do another query on lead based on the found lead Ids.

Set<Id> lstLeadIds = new Set<Id>();
for(CampaignMember cm : [SELECT LeadId FROM CampaignMember WHERE CampaignId =:campaignId ) {
    lstLeadIds.add(cm.LeadId); 
}

//Query lead records 
List<Lead> lstLeads = [SELECT Id, Name, Phone, Email FROM Lead WHERE Id IN :lstLeadIds];

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.