+ Start a Discussion
Patrick G. BrownPatrick G. Brown 

Update Campaign Member from Campaign

I have a checkbox field on my Campaign Member records called Campaign_IsActive__c.  Using a trigger, I'd like when my Campaign IsActive = FALSE, to update the Campagin_IsActive__c on my Campaign Member records.

I've been working on a trigger for a few days and continue to run into roadblocks.  I'm currently facing an error stating: Variable Does Not Exist: 'CampaignMember'.

Can anyone please point me in the right direction?  Once I can get the list, I'll be able to update the field.  But I have had the hardest time simply getting a list of CampaignMembers from Campaigns.
trigger deactivateCampaignMember on Campaign (after insert) {
        Map<id, list<CampaignMember>> campaignMemberMap = new Map<Id, List<CampaignMember>>();
        for(campaign camp : [SELECT Id, (SELECT LeadId,ContactId FROM CampaignMembers) FROM Campaign])
            list<CampaignMember> campMemebersList = camp.CampaignMember;
            if(campMemebersList!= null)
                campaignMemberMap.put(camp.Id, campMemebersList);


Best Answer chosen by Patrick G. Brown
Shivdeep KumarShivdeep Kumar
Hi Patrick,

In line number 8, use (list<CampaignMember> campMemebersList = camp.CampaignMembers;)
your error will be resolve.