I am trying to refer the element(listname.contactid
) from the list but I am getting error:
Variable doesn't exist error
However I am getting the entire list when I just use list name.
I know I that I am doing something wrong.
Can someone please help me solve this guide me to learn the cause of the this. Thank you. Code is given below.
trigger dlrs_CampaignMemberTrigger on CampaignMember(after delete, after insert) {
list campaignlist = new list();
set cmpId = new set();
if (trigger.isDelete) { //system.debug(trigger.old);
for (CampaignMember campMem: trigger.old) {
CampaignMember cpm = new CampaignMember();
cpm.CampaignId = campMem.CampaignId;
cpm.contactid = campmem.contactid;
cpm.LeadId = campmem.LeadId;
campaignlist.add(cpm); //error Method does not exist or incorrect signature: void add(CampaignMember) from the type CampaignMember
cmpId.add(campMem.CampaignId);
system.debug(campaignlist);
system.debug(campaignlist.contactid); //---- error Variable doesn't exist: contactid
}
campaign[] campname = [select name from campaign where Id in: cmpId];
system.debug(campname);
}
}