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
riffindusriffindus 

Not able to pull campaign from the lead object

Hi,

 

I am trying to get the campaign id from the lead object but it is returning as null.

 

Set<ID> LeadIDs = new Set<ID>();
for(Lead l: lstLead) {
LeadIDs.add(l.id);
}

for(CampaignMember cM : [Select LeadId, CampaignId from CampaignMember where LeadId IN :LeadIDs]) {
system.debug('campiagn member test'+cM.leadid);
system.debug('campiagn member test'+cM.CampaignId);
MapFinalCampaignToLead.put(cM.LeadId,cM.CampaignId);

}

system.debug('MapFinalCampaignToLead'+MapFinalCampaignToLead.size());

 

 

i tried querying Select LeadId, CampaignId from CampaignMember where LeadId = 'XXX' it shows the campaign it if i comment out the convert code but when i have this code in my class which converts the lead to opp it is returining as NULL

 

Not converting lead - Querying - Gives camapign ID with same SOQL

 

Before converting - Querying - no campaign id returned.

 

Any help?

 

Regards

riffind

riffindusriffindus

Please someone help me

 

I am stuck without this campaign value

 

riffind