• V.S.K. Chowdary
  • NEWBIE
  • 0 Points
  • Member since 2012

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

Hi All,

 

   I am  moving  tiggers from sanboz to production  account .  I  production account i have 34,240  records ,   wihile  validate the trigger in production  i am  gettting Error  like Failure Message: "System.LimitException: Too many query rows: 50001", Failure Stack Trace: "(System Code) Trigger.campMemberTrig: line 6, column 1"

 

 

 my trigger is

 

 

 

Trigger:
trigger campMemberTrig on CampaignMember (before insert, before update) {
    
 
    Map<Id, Contact> mpCon = new Map<Id, Contact>();
       list<contact> conlist=new list<contact>();
       for(Contact c: [Select id, name,email,HasOptedOutOfEmail from Contact limit 50000])----------6th line
        mpcon.put(c.id,c);
    id contactid;
     for(CampaignMember  cm:trigger.New)  {
    if(cm.status=='Opted Out'&&trigger.isinsert)
      contactid=cm.contactid; 
    else if(trigger.isupdate)
    if(trigger.oldmap.get(cm.id).status!='Opted Out'&&cm.status=='Opted Out')
    contactid=cm.contactid; 
   } 
  
    is  there any  help to  solve  this error