I want to update a field on the related contacts of a campaign with a field of the related campaign when the campaing is updated. I can get the contactid trough CampaignMembers but how do I get the contact in a bulkified way?
I tried the following but this would mean I would have to query the current contact in the loop:
public static void updateRelatedContactFields(List<Campaign> newlist) {
List<Campaign> campRelContact = [Select id, ACS__c ,
(SELECT contactid
FROM CampaignMembers) FROM Campaign
WHERE id in :newlist];
for(Campaign camp : campRelContact){
for(CampaignMember c : camp.CampaignMembers){
//get contact and update
}
}
}