You need to sign in to do that
Don't have an account?
Initial term of field expression must be a concrete SObject: LIST
I want to update Contact when Status of Campaign Member is changed. I code below but got error "Initial term of field expression must be a concrete SObject: LIST<CampaignMember> at line 18 column 114" when compile. May I know why?
trigger UpdateContactafterinsertCampaignMember on CampaignMember (after insert) {
Map<Id, List<CampaignMember>> CampaignMembersByContactId = new Map<Id, List<CampaignMember>>();
for (CampaignMember campmem : trigger.new) {
if(campmem.Contact_Type__c == 'First Contact'){
if (CampaignMembersByContactId.containsKey(campmem.ContactId)) {
CampaignMembersByContactId.get(campmem.ContactId).add(campmem);
}//end if
else {
List<CampaignMember> temp = new List<CampaignMember>();
temp.add(campmem);
CampaignMembersByContactId.put(campmem.ContactId, temp);
}//end else
}//end if
}//end for
Map<Id, Contact> ContactsById = new Map<Id, Contact>([SELECT Id FROM Contact WHERE Id in :CampaignMembersByContactId.keySet()]);
for(Id ContactId : CampaignMembersByContactId.keyset()) {
if(CampaignMembersByContactId.stage__c == '1' ) {
ContactsById.get(contactId).Stage_1_Date__c = CampaignMembersByContactId.get(contactId).Created_Date__c;
ContactsById.get(contactId).stage_1_Status__c = CampaignMembersByContactId.get(contactId).Status;
}//end if
Your issue is with these two lines:
Your Map "CampaignMembersByContactID is a map of a ID and a list of CampaignMembers, so your get would return a list of results, not a single result.
You need to identify which CampaignMember from the list you want to get the Stage 1 date and stage 1 status values from.
May I know how to do that?
solved.