what I can understand from your code is you are trying to access contactId from a List type variable. system.debug(campaignlist.contactid); //---- error Variable doesn't exist:
system.debug(campaignlist.contactid); //---- error Variable doesn't exist:
You need to iterate through campaignList and then access the contactid like below: for(CampaignMember cmp :campaignlist){ cmp.contactId; system.debug('contact id '+cmp.contactId); }
for(CampaignMember cmp :campaignlist){
cmp.contactId;
system.debug('contact id '+cmp.contactId);
}