• LauraStephens
  • NEWBIE
  • 0 Points
  • Member since 2013

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 6
    Replies

Hello everyone,

 

I created a trigger on Campaign Member and the purpose is to update the fields of the campaign member from the Lead it is associated with.

 

I am not able to figure out why the code is not updating the campaign member record even though it is hitting the code:

 

Following is my trigger:

 

trigger CampaignMemberAfter on CampaignMember(after insert, after update, after delete)
{

List<CampaignMember> camMembers = trigger.IsInsert || trigger.IsUpdate ? trigger.new : trigger.old;

if(trigger.isUpdate)

{
CampaignMemberClass.UpdateCampaignMember(camMembers);
}


}

 

 

 

Following is my class:

 

public class CampaignMemberClass
{

public static void UpdateCampaignMember(List<CampaignMember> camMembers)

{

Map<Id,CampaignMember> campaignLeads = new Map<Id,CampaignMember>{};

Map<Id,CampaignMember> campaignMems = new Map<Id,CampaignMember>{};

for(CampaignMember cm : camMembers)
{
campaignLeads.put(cm.LeadId, cm);
campaignMems.put(cm.Id, cm);
}

List<CampaignMember> CMsToUpdate = new List<CampaignMember>{};

for(CampaignMember CMem : [Select LeadId,Id,Lead.avg_attendance__c,Lead.avg_ticket_price__c,Lead.Estimated_Annual_Revenue__c,Average_Attendance__c, Average_Ticket_Price__c, Estimated_Annual_Rev__c from CampaignMember where Id in :campaignMems.keySet()])
{


CMem.Average_Attendance__c = Cmem.Lead.avg_attendance__c ;
CMem.Average_Ticket_Price__c = CMem.Lead.avg_ticket_price__c ;
CMem.Estimated_Annual_Rev__c = CMem.Lead.Estimated_Annual_Revenue__c;
CMem.Lead_Status__c = 'Open';

System.debug('AVERAGE ATTENDANCE LEAD VALUE '+ Cmem.Lead.avg_attendance__c);
System.debug('AVERAGE ATTENDANCE LEAD VALUE '+ Cmem.Lead.avg_ticket_price__c);
System.debug('AVERAGE ATTENDANCE LEAD VALUE '+ Cmem.Lead.avg_attendance__c);




CMsToUpdate.add(CMem) ;

}





}




}

 

Please help me in figuring out what I am missing.

 

 

Hello everyone,

 

I created a trigger on Campaign Member and the purpose is to update the fields of the campaign member from the Lead it is associated with.

 

I am not able to figure out why the code is not updating the campaign member record even though it is hitting the code:

 

Following is my trigger:

 

trigger CampaignMemberAfter on CampaignMember(after insert, after update, after delete)
{

List<CampaignMember> camMembers = trigger.IsInsert || trigger.IsUpdate ? trigger.new : trigger.old;

if(trigger.isUpdate)

{
CampaignMemberClass.UpdateCampaignMember(camMembers);
}


}

 

 

 

Following is my class:

 

public class CampaignMemberClass
{

public static void UpdateCampaignMember(List<CampaignMember> camMembers)

{

Map<Id,CampaignMember> campaignLeads = new Map<Id,CampaignMember>{};

Map<Id,CampaignMember> campaignMems = new Map<Id,CampaignMember>{};

for(CampaignMember cm : camMembers)
{
campaignLeads.put(cm.LeadId, cm);
campaignMems.put(cm.Id, cm);
}

List<CampaignMember> CMsToUpdate = new List<CampaignMember>{};

for(CampaignMember CMem : [Select LeadId,Id,Lead.avg_attendance__c,Lead.avg_ticket_price__c,Lead.Estimated_Annual_Revenue__c,Average_Attendance__c, Average_Ticket_Price__c, Estimated_Annual_Rev__c from CampaignMember where Id in :campaignMems.keySet()])
{


CMem.Average_Attendance__c = Cmem.Lead.avg_attendance__c ;
CMem.Average_Ticket_Price__c = CMem.Lead.avg_ticket_price__c ;
CMem.Estimated_Annual_Rev__c = CMem.Lead.Estimated_Annual_Revenue__c;
CMem.Lead_Status__c = 'Open';

System.debug('AVERAGE ATTENDANCE LEAD VALUE '+ Cmem.Lead.avg_attendance__c);
System.debug('AVERAGE ATTENDANCE LEAD VALUE '+ Cmem.Lead.avg_ticket_price__c);
System.debug('AVERAGE ATTENDANCE LEAD VALUE '+ Cmem.Lead.avg_attendance__c);




CMsToUpdate.add(CMem) ;

}





}




}

 

Please help me in figuring out what I am missing.

 

 

Hello there.

I found a section of apex coding that will, coupled with a round robin case assignment app, assign leads for me. I followed their instructions, but I am getting the error below. I also posted a link to the coding. What am I missing?

 


Error: Compile Error: unexpected token: trigger at line 135 column 0 

 

 

https://gist.github.com/1562280