• pothadi
  • NEWBIE
  • 0 Points
  • Member since 2009

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 5
    Questions
  • 14
    Replies

Hi,

 

i have implemented the @future annotation for updating Leads. It is working fine in the sandbox account and able to update 1005 records sucessfully. The same Trigger and Apex Class deployed in the Production site  and  trying to update 33 Lead records, it's giving "Too many query rows:10001" error.  In the Production server we have upto 40,000 leads.

 

Here is my Trigger:

 

trigger Update_Invitation_Letter_Send_Date on Campaign (after update) {

 

     if (Trigger.new.size()==1)

   {

         Campaign oCampaign = Trigger.new[0];             if (oCampaign.Id!=null)

         {

             CampaignUpdateInvitation.CampaignUpdateInvitationMethod(oCampaign.Id,oCampaign.Invitation_Letter_Sent_Date__c);

          }

     }

}

 

 

 

Here is my Apex @Future annotation Class:

 

global class CampaignUpdateInvitation {

@future

     Public static void CampaignUpdateInvitationMethod(String Cid,Date Invitationdae)

    {

          List<lead> updLead = new List<lead>();

 

            if(Cid!=null){                       for(Lead tmpLead:[Select Id,Seat_Letter_Sent__c from Lead Where Id in (Select LeadId from CampaignMember          Where CampaignId=:Cid)]){

 

                          if(tmpLead.Seat_Letter_Sent__c == null){

                               tmpLead.Seat_Letter_Sent__c=Invitationdae;

                               updLead.add(tmpLead);

                                      if(updLead.size()==100){                                                update updLead;

                                    updLead.clear();

                               }

                     }

             }

   }

         if(updLead.size()>0){               update updLead ;

       }

}

 

static testMethod void testCampaignUpdateInvitationMethod()

{

Test.startTest();

 

Campaign OCampaign = new Campaign(Name = 'Anovatek Testing', Description= 'Anovatek Testing is Started',Invitation_Letter_Sent_Date__c=System.today()); insert OCampaign ;

 

Lead OLead = new Lead(Status = '2-Invitation Letter Sent', LastName = 'Test', Company = 'Test',TAB_Lead_Owner__c = 'Test12',Seat_Letter_Sent__c=System.today());

insert OLead;

 

Lead OLead1 = new Lead(Status = '2-Invitation Letter Sent', LastName = 'Test4', Company = 'Test',TAB_Lead_Owner__c = 'Test14',Seat_Letter_Sent__c=System.today()); insert OLead1;

 

Lead OLead2 = new Lead(Status = '2-Invitation Letter Sent', LastName = 'Test4', Company = 'Test',TAB_Lead_Owner__c = 'Test14',Seat_Letter_Sent__c=System.today());

insert OLead2;

 

 

CampaignMember cCampaignMember = new CampaignMember(CampaignId=OCampaign.Id, LeadId=OLead.Id,Status='Sent');

Insert cCampaignMember ;

 

CampaignMember cCampaignMember1 = new CampaignMember(CampaignId=OCampaign.Id, LeadId=OLead1.Id,Status='Sent');

Insert cCampaignMember1 ;

 

CampaignMember cCampaignMember2 = new CampaignMember(CampaignId=OCampaign.Id, LeadId=OLead2.Id,Status='Sent');

Insert cCampaignMember2 ;

 

 

List<CampaignMember> exCampaignMember=[Select LeadId from CampaignMember Where CampaignId = :smileysurprised:Campaign.Id];

 

Lead lLead1 = [Select TAB_Lead_Owner__c,Id,Seat_Letter_Sent__c From Lead where Id = :smileysurprised:Lead.Id];

lLead1.Seat_Letter_Sent__c =System.today();

update lLead1;

 

Lead lLead2 = [Select TAB_Lead_Owner__c,Id,Seat_Letter_Sent__c From Lead where Id = :smileysurprised:Lead1.Id];

lLead2.Seat_Letter_Sent__c =System.today();

update lLead2;

 

Campaign SCampaign1 = [Select Name,Description,Invitation_Letter_Sent_Date__c From Campaign where Id = :smileysurprised:Campaign.Id];

SCampaign1.Invitation_Letter_Sent_Date__c =System.today();

update SCampaign1;

 

Test.stopTest();

 

}

}

 

 Can any one please help me on this.

 

 

i will appreciate your help.

 

 

Thank you.

Hi,

 

i have implemented the @future annotation for updating Leads. It is working fine in the sandbox account and able to update 1005 records sucessfully. The same Trigger and Apex Class deployed in the Production site  and  trying to update 33 Lead records, it's giving Too many query rows:10001.  In the Production server we have upto 40,000 leads.

 

Here is my Trigger:

 

trigger Update_Invitation_Letter_Send_Date on Campaign (after update) {

 

     if (Trigger.new.size()==1)

   {

         Campaign oCampaign = Trigger.new[0];             if (oCampaign.Id!=null)

         {

             CampaignUpdateInvitation.CampaignUpdateInvitationMethod(oCampaign.Id,oCampaign.Invitation_Letter_Sent_Date__c);

          }

     }

}

 

 

 

Here is my Apex @Future annotation Class:

 

global class CampaignUpdateInvitation {

@future

     Public static void CampaignUpdateInvitationMethod(String Cid,Date Invitationdae)

    {

          List<lead> updLead = new List<lead>();

 

            if(Cid!=null){                       for(Lead tmpLead:[Select Id,Seat_Letter_Sent__c from Lead Where Id in (Select LeadId from CampaignMember          Where CampaignId=:Cid)]){

 

                          if(tmpLead.Seat_Letter_Sent__c == null){

                               tmpLead.Seat_Letter_Sent__c=Invitationdae;

                               updLead.add(tmpLead);

                                      if(updLead.size()==100){                                                update updLead;

                                    updLead.clear();

                               }

                     }

             }

   }

         if(updLead.size()>0){               update updLead ;

       }

}

 

static testMethod void testCampaignUpdateInvitationMethod()

{

Test.startTest();

 

Campaign OCampaign = new Campaign(Name = 'Anovatek Testing', Description= 'Anovatek Testing is Started',Invitation_Letter_Sent_Date__c=System.today()); insert OCampaign ;

 

Lead OLead = new Lead(Status = '2-Invitation Letter Sent', LastName = 'Test', Company = 'Test',TAB_Lead_Owner__c = 'Test12',Seat_Letter_Sent__c=System.today());

insert OLead;

 

Lead OLead1 = new Lead(Status = '2-Invitation Letter Sent', LastName = 'Test4', Company = 'Test',TAB_Lead_Owner__c = 'Test14',Seat_Letter_Sent__c=System.today()); insert OLead1;

 

Lead OLead2 = new Lead(Status = '2-Invitation Letter Sent', LastName = 'Test4', Company = 'Test',TAB_Lead_Owner__c = 'Test14',Seat_Letter_Sent__c=System.today());

insert OLead2;

 

 

CampaignMember cCampaignMember = new CampaignMember(CampaignId=OCampaign.Id, LeadId=OLead.Id,Status='Sent');

Insert cCampaignMember ;

 

CampaignMember cCampaignMember1 = new CampaignMember(CampaignId=OCampaign.Id, LeadId=OLead1.Id,Status='Sent');

Insert cCampaignMember1 ;

 

CampaignMember cCampaignMember2 = new CampaignMember(CampaignId=OCampaign.Id, LeadId=OLead2.Id,Status='Sent');

Insert cCampaignMember2 ;

 

 

List<CampaignMember> exCampaignMember=[Select LeadId from CampaignMember Where CampaignId = :OCampaign.Id];

 

Lead lLead1 = [Select TAB_Lead_Owner__c,Id,Seat_Letter_Sent__c From Lead where Id = :OLead.Id];

lLead1.Seat_Letter_Sent__c =System.today();

update lLead1;

 

Lead lLead2 = [Select TAB_Lead_Owner__c,Id,Seat_Letter_Sent__c From Lead where Id = :OLead1.Id];

lLead2.Seat_Letter_Sent__c =System.today();

update lLead2;

 

Campaign SCampaign1 = [Select Name,Description,Invitation_Letter_Sent_Date__c From Campaign where Id = :OCampaign.Id];

SCampaign1.Invitation_Letter_Sent_Date__c =System.today();

update SCampaign1;

 

Test.stopTest();

 

}

}

 

 Can any one please help me on this.

 

 

i will appreciate your help.

 

 

Thank you.

 

 

Hi,

 

I am tring to update 1005 Lead records under Campaign Trigger . i used @future annotation also., still i am getting "collection exceeds maximum size:1001" script error.

 

Here is my Trigger:

 

trigger Update_Invitation_Letter_Send_Date on Campaign (before update) {
   
    if (Trigger.new.size()==1)
    {       
        Campaign oCampaign =  Trigger.new[0];      
        if (oCampaign.Id!=null)
        {   
           CampaignUpdateInvitation.CampaignUpdateInvitationMethod(oCampaign.Id,oCampaign.Invitation_Letter_Sent_Date__c);   
        }  
     }    
 }

 

 

Here is my Apex Class used @future annotation:

 

global class CampaignUpdateInvitation {
    @future
    Public static void CampaignUpdateInvitationMethod(String Cid,Date Invitationdae)
    { 
        List<lead> updLead = new List<lead>();
        List<Campaign> updCampaign = new List<Campaign>();
        Set<Id> LeadIds = new Set<Id>();
       
        for(Lead tmpLead:[Select Id,Seat_Letter_Sent__c from Lead Where Id in (Select LeadId from CampaignMember Where CampaignId=:Cid)]){
   
            if(!LeadIds.contains(tmpLead.Id)){
       
                //if(tmpLead.Seat_Letter_Sent__c == null)
                //{
                    tmpLead.Seat_Letter_Sent__c=Invitationdae;
                     
                    updLead.add(tmpLead);
                    LeadIds.add(tmpLead.Id);
               
                    if(updLead.size()==100)
                    {
                       update updLead;
                       updLead.clear();
                    }   
               // }              
               
            }
         }            
                        
         if(updLead.size()>0){
            update updLead ;
         }            
            
                   
   }
  
   static testMethod void testCampaignUpdateInvitationMethod()
   {  
        Test.startTest();
       
        Campaign OCampaign = new Campaign(Name = 'Anovatek Testing', Description= 'Anovatek Testing is Started',Invitation_Letter_Sent_Date__c=System.today());
        insert OCampaign ; 
       
        Campaign  SCampaign1 = [Select Name,Description,Invitation_Letter_Sent_Date__c From Campaign where Id = :OCampaign.Id];
        SCampaign1.Invitation_Letter_Sent_Date__c =System.today();
        update SCampaign1; 
            
        Test.stopTest();               
       
    }
}

 

under CampaignMember Object i have 1005 records. it's updating 1000 records. then it is giving exception saying that "collection exceeds maximum size:1001".

 

please any body can help me on this.

 

i appreciate your help.

 

 

Thanks.

hi ,

 

For the below Trigger and testmethod, i am geting 47% test coverage.

 

Here is my Trigger:

 

trigger Update_Invitation_Letter_Send_Date on Campaign (before insert,before update) {
   
    List<Id> CId = new List<Id>();
    List<lead> updLead = new List<lead>();
    Set<Id> LeadIds = new Set<Id>();
   
    for(Campaign oCampaign : Trigger.new){
        CId.add(oCampaign.Id);  
    }
   
    List<Lead> exLead =[Select Id,Seat_Letter_Sent__c,Type__c from Lead Where Id in (Select LeadId from CampaignMember Where CampaignId in:CId)];
    for(Campaign oCampaign : Trigger.new){
      if(exLead.Size() > 0){
         for(Lead tmpLead:exLead){
            if(!LeadIds.contains(tmpLead.Id)){
           
            if(oCampaign.Invitation_Letter_Sent_Date__c!=null)
            {
                tmpLead.Seat_Letter_Sent__c=oCampaign.Invitation_Letter_Sent_Date__c;
            }
           
            //if(oCampaign.Type!=null)
            //{
                //tmpLead.Type__c=oCampaign.Type;
            //}
           
            updLead.add(tmpLead);
            LeadIds.add(tmpLead.Id);
           
            if(updLead.size()==100)
            {
               update updLead;
               updLead.clear();
            }
           
           }
         }
      }
    }
    if(updLead.size()>0){
        update updLead ;
    }
 }

 

 

Here is my Test Method:

 

 public class Campaign_Invitation_Letter {

    public static testMethod void CamapaignInvitationLetterHelper()
    { 
       Campaign OCampaign = new Campaign(Name = 'Anovatek Testing', Description= 'Anovatek Testing is Started',Invitation_Letter_Sent_Date__c=System.today());
       insert OCampaign ;   
       
       Lead OLead = new Lead(Status = '2-Invitation Letter Sent', LastName = 'Test', Company = 'Test',TAB_Lead_Owner__c = 'Test12',Seat_Letter_Sent__c=System.today());
       insert OLead;
       
       Lead OLead1 = new Lead(Status = '2-Invitation Letter Sent', LastName = 'Test4', Company = 'Test',TAB_Lead_Owner__c = 'Test14',Seat_Letter_Sent__c=System.today());
       insert OLead1;
      
       Lead OLead2 = new Lead(Status = '2-Invitation Letter Sent', LastName = 'Test4', Company = 'Test',TAB_Lead_Owner__c = 'Test14',Seat_Letter_Sent__c=System.today());
       insert OLead2;

                    
       CampaignMember cCampaignMember = new CampaignMember(CampaignId=OCampaign.Id, LeadId=OLead.Id,Status='Sent');
       Insert cCampaignMember ;
      
       CampaignMember cCampaignMember1 = new CampaignMember(CampaignId=OCampaign.Id, LeadId=OLead1.Id,Status='Sent');
       Insert cCampaignMember1 ;
      
       CampaignMember cCampaignMember2 = new CampaignMember(CampaignId=OCampaign.Id, LeadId=OLead2.Id,Status='Sent');
       Insert cCampaignMember2 ;

      
       List<CampaignMember> exCampaignMember=[Select LeadId from CampaignMember Where CampaignId = :OCampaign.Id];
       
       Lead lLead1 = [Select TAB_Lead_Owner__c,Id,Seat_Letter_Sent__c From Lead where Id = :OLead.Id];
       lLead1.Seat_Letter_Sent__c =System.today();
       update lLead1;
      
        Lead lLead2 = [Select TAB_Lead_Owner__c,Id,Seat_Letter_Sent__c From Lead where Id = :OLead1.Id];
        lLead2.Seat_Letter_Sent__c =System.today();
        update lLead2;

      
     }
}

 

 

can anyone help me on this, to improve the Test Coverage percentage to 75%. where i need to move this to production server.

 

i appreciate your help.

 

 

 

Thanks.

Hi,

 

 

my requiment is: In my Sandbox salesforce account, where i have one Campaign and more than 1000 Leads. i am trying to add 1000 to Campaign object in the CampaignMember details page. i am able to add 1000 leads successfully to One Campaign.  after adding leads,   i Created one Trigger on the Campaign object with before update event.  i am unable to updae Campaign record.

 

Error:  Apex trigger Update_Invitation_Letter_Send_Date caused an unexpected exception, contact your administrator: Update_Invitation_Letter_Send_Date: execution of BeforeUpdate caused by: System.DmlException: Update failed. First exception on row 0 with id 00QS000000314woMAA; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, Update_Tab_Owner_Lead: execution of AfterUpdate caused by: System.Exception: Too many DML rows: 189 Trigger.Update_Tab_Owner_Lead: line 48, column 9: []: Trigger.Update_Invitation_Letter_Send_Date: line 42, column 28.

 

 Here is my Trigger :

 

 

trigger Update_Invitation_Letter_Send_Date on Campaign (before update) {
   
    List<Id> CId = new List<Id>();
    List<lead> updLead = new List<lead>();
    Set<Id> LeadIds = new Set<Id>();
    Set<Id> CampaignIds = new Set<Id>();

   
    for(Campaign oCampaign : Trigger.new){
       if(!CampaignIds.contains(oCampaign.Id)){
            CId.add(oCampaign.Id);
            CampaignIds.add(oCampaign.Id);
        }
 
    }
   
    List<Lead> exLead =[Select Id,Seat_Letter_Sent__c,Type__c from Lead Where Id in (Select LeadId from CampaignMember Where CampaignId in:CId)];
   
    for(Campaign oCampaign : Trigger.new){
   
      if(exLead.Size() > 0){
     
             for(Lead tmpLead:exLead){
            
                  if(!LeadIds.contains(tmpLead.Id)){
                   
                        if(oCampaign.Invitation_Letter_Sent_Date__c!=null)
                        {
                            tmpLead.Seat_Letter_Sent__c=oCampaign.Invitation_Letter_Sent_Date__c;
                        }
                       
                        //if(oCampaign.Type!=null)
                        //{
                            //tmpLead.Type__c=oCampaign.Type;
                        //}
                       
                        updLead.add(tmpLead);
                        LeadIds.add(tmpLead.Id);
                       
                        if(updLead.Size()==100)
                        {
                           update updLead;
                           updLead.clear();
                        }
                   
                   }
             }
      }
    }
   
     if(updLead.Size()> 0 ){
        update updLead ;
    }
  
 }

 

 

Here is my Run test Method:

 

 

@isTest
private class Campaign_Invitation_Letter {

    private static testMethod void CamapaignInvitationLetterHelper()
    { 
       Campaign OCampaign = new Campaign(Name = 'Anovatek Testing', Description= 'Anovatek Testing is Started',Invitation_Letter_Sent_Date__c=System.today());
       insert OCampaign ;   
       
       Lead OLead = new Lead(FirstName= 'Take',LastName='solutions',Company='Take Enterprises', Description= 'Take Testing is Started',Status='New Prospect',Seat_Letter_Sent__c=System.today());
       insert OLead ;
            
       CampaignMember cCampaignMember  =new CampaignMember(CampaignId=OCampaign.Id, LeadId=OLead.Id);
       Insert cCampaignMember ;

       
        Lead lLead = [Select Id,Seat_Letter_Sent__c from Lead Where Id in (Select LeadId from CampaignMember Where CampaignId in:OCampaign.Id)];
        lLead.Seat_Letter_Sent__c = OCampaign.Invitation_Letter_Sent_Date__c;
        update lLead;

     }
}

 

 

When i am updating the Campaign record, i am getting above. error.

 

can please any body help me on this issue.

 

i will appreciate you help.

 

Thanks in advance.

 

 

with,

Pothadi 

 

Hi,

 

i have implemented the @future annotation for updating Leads. It is working fine in the sandbox account and able to update 1005 records sucessfully. The same Trigger and Apex Class deployed in the Production site  and  trying to update 33 Lead records, it's giving "Too many query rows:10001" error.  In the Production server we have upto 40,000 leads.

 

Here is my Trigger:

 

trigger Update_Invitation_Letter_Send_Date on Campaign (after update) {

 

     if (Trigger.new.size()==1)

   {

         Campaign oCampaign = Trigger.new[0];             if (oCampaign.Id!=null)

         {

             CampaignUpdateInvitation.CampaignUpdateInvitationMethod(oCampaign.Id,oCampaign.Invitation_Letter_Sent_Date__c);

          }

     }

}

 

 

 

Here is my Apex @Future annotation Class:

 

global class CampaignUpdateInvitation {

@future

     Public static void CampaignUpdateInvitationMethod(String Cid,Date Invitationdae)

    {

          List<lead> updLead = new List<lead>();

 

            if(Cid!=null){                       for(Lead tmpLead:[Select Id,Seat_Letter_Sent__c from Lead Where Id in (Select LeadId from CampaignMember          Where CampaignId=:Cid)]){

 

                          if(tmpLead.Seat_Letter_Sent__c == null){

                               tmpLead.Seat_Letter_Sent__c=Invitationdae;

                               updLead.add(tmpLead);

                                      if(updLead.size()==100){                                                update updLead;

                                    updLead.clear();

                               }

                     }

             }

   }

         if(updLead.size()>0){               update updLead ;

       }

}

 

static testMethod void testCampaignUpdateInvitationMethod()

{

Test.startTest();

 

Campaign OCampaign = new Campaign(Name = 'Anovatek Testing', Description= 'Anovatek Testing is Started',Invitation_Letter_Sent_Date__c=System.today()); insert OCampaign ;

 

Lead OLead = new Lead(Status = '2-Invitation Letter Sent', LastName = 'Test', Company = 'Test',TAB_Lead_Owner__c = 'Test12',Seat_Letter_Sent__c=System.today());

insert OLead;

 

Lead OLead1 = new Lead(Status = '2-Invitation Letter Sent', LastName = 'Test4', Company = 'Test',TAB_Lead_Owner__c = 'Test14',Seat_Letter_Sent__c=System.today()); insert OLead1;

 

Lead OLead2 = new Lead(Status = '2-Invitation Letter Sent', LastName = 'Test4', Company = 'Test',TAB_Lead_Owner__c = 'Test14',Seat_Letter_Sent__c=System.today());

insert OLead2;

 

 

CampaignMember cCampaignMember = new CampaignMember(CampaignId=OCampaign.Id, LeadId=OLead.Id,Status='Sent');

Insert cCampaignMember ;

 

CampaignMember cCampaignMember1 = new CampaignMember(CampaignId=OCampaign.Id, LeadId=OLead1.Id,Status='Sent');

Insert cCampaignMember1 ;

 

CampaignMember cCampaignMember2 = new CampaignMember(CampaignId=OCampaign.Id, LeadId=OLead2.Id,Status='Sent');

Insert cCampaignMember2 ;

 

 

List<CampaignMember> exCampaignMember=[Select LeadId from CampaignMember Where CampaignId = :smileysurprised:Campaign.Id];

 

Lead lLead1 = [Select TAB_Lead_Owner__c,Id,Seat_Letter_Sent__c From Lead where Id = :smileysurprised:Lead.Id];

lLead1.Seat_Letter_Sent__c =System.today();

update lLead1;

 

Lead lLead2 = [Select TAB_Lead_Owner__c,Id,Seat_Letter_Sent__c From Lead where Id = :smileysurprised:Lead1.Id];

lLead2.Seat_Letter_Sent__c =System.today();

update lLead2;

 

Campaign SCampaign1 = [Select Name,Description,Invitation_Letter_Sent_Date__c From Campaign where Id = :smileysurprised:Campaign.Id];

SCampaign1.Invitation_Letter_Sent_Date__c =System.today();

update SCampaign1;

 

Test.stopTest();

 

}

}

 

 Can any one please help me on this.

 

 

i will appreciate your help.

 

 

Thank you.

Hi,

 

I am tring to update 1005 Lead records under Campaign Trigger . i used @future annotation also., still i am getting "collection exceeds maximum size:1001" script error.

 

Here is my Trigger:

 

trigger Update_Invitation_Letter_Send_Date on Campaign (before update) {
   
    if (Trigger.new.size()==1)
    {       
        Campaign oCampaign =  Trigger.new[0];      
        if (oCampaign.Id!=null)
        {   
           CampaignUpdateInvitation.CampaignUpdateInvitationMethod(oCampaign.Id,oCampaign.Invitation_Letter_Sent_Date__c);   
        }  
     }    
 }

 

 

Here is my Apex Class used @future annotation:

 

global class CampaignUpdateInvitation {
    @future
    Public static void CampaignUpdateInvitationMethod(String Cid,Date Invitationdae)
    { 
        List<lead> updLead = new List<lead>();
        List<Campaign> updCampaign = new List<Campaign>();
        Set<Id> LeadIds = new Set<Id>();
       
        for(Lead tmpLead:[Select Id,Seat_Letter_Sent__c from Lead Where Id in (Select LeadId from CampaignMember Where CampaignId=:Cid)]){
   
            if(!LeadIds.contains(tmpLead.Id)){
       
                //if(tmpLead.Seat_Letter_Sent__c == null)
                //{
                    tmpLead.Seat_Letter_Sent__c=Invitationdae;
                     
                    updLead.add(tmpLead);
                    LeadIds.add(tmpLead.Id);
               
                    if(updLead.size()==100)
                    {
                       update updLead;
                       updLead.clear();
                    }   
               // }              
               
            }
         }            
                        
         if(updLead.size()>0){
            update updLead ;
         }            
            
                   
   }
  
   static testMethod void testCampaignUpdateInvitationMethod()
   {  
        Test.startTest();
       
        Campaign OCampaign = new Campaign(Name = 'Anovatek Testing', Description= 'Anovatek Testing is Started',Invitation_Letter_Sent_Date__c=System.today());
        insert OCampaign ; 
       
        Campaign  SCampaign1 = [Select Name,Description,Invitation_Letter_Sent_Date__c From Campaign where Id = :OCampaign.Id];
        SCampaign1.Invitation_Letter_Sent_Date__c =System.today();
        update SCampaign1; 
            
        Test.stopTest();               
       
    }
}

 

under CampaignMember Object i have 1005 records. it's updating 1000 records. then it is giving exception saying that "collection exceeds maximum size:1001".

 

please any body can help me on this.

 

i appreciate your help.

 

 

Thanks.

hi ,

 

For the below Trigger and testmethod, i am geting 47% test coverage.

 

Here is my Trigger:

 

trigger Update_Invitation_Letter_Send_Date on Campaign (before insert,before update) {
   
    List<Id> CId = new List<Id>();
    List<lead> updLead = new List<lead>();
    Set<Id> LeadIds = new Set<Id>();
   
    for(Campaign oCampaign : Trigger.new){
        CId.add(oCampaign.Id);  
    }
   
    List<Lead> exLead =[Select Id,Seat_Letter_Sent__c,Type__c from Lead Where Id in (Select LeadId from CampaignMember Where CampaignId in:CId)];
    for(Campaign oCampaign : Trigger.new){
      if(exLead.Size() > 0){
         for(Lead tmpLead:exLead){
            if(!LeadIds.contains(tmpLead.Id)){
           
            if(oCampaign.Invitation_Letter_Sent_Date__c!=null)
            {
                tmpLead.Seat_Letter_Sent__c=oCampaign.Invitation_Letter_Sent_Date__c;
            }
           
            //if(oCampaign.Type!=null)
            //{
                //tmpLead.Type__c=oCampaign.Type;
            //}
           
            updLead.add(tmpLead);
            LeadIds.add(tmpLead.Id);
           
            if(updLead.size()==100)
            {
               update updLead;
               updLead.clear();
            }
           
           }
         }
      }
    }
    if(updLead.size()>0){
        update updLead ;
    }
 }

 

 

Here is my Test Method:

 

 public class Campaign_Invitation_Letter {

    public static testMethod void CamapaignInvitationLetterHelper()
    { 
       Campaign OCampaign = new Campaign(Name = 'Anovatek Testing', Description= 'Anovatek Testing is Started',Invitation_Letter_Sent_Date__c=System.today());
       insert OCampaign ;   
       
       Lead OLead = new Lead(Status = '2-Invitation Letter Sent', LastName = 'Test', Company = 'Test',TAB_Lead_Owner__c = 'Test12',Seat_Letter_Sent__c=System.today());
       insert OLead;
       
       Lead OLead1 = new Lead(Status = '2-Invitation Letter Sent', LastName = 'Test4', Company = 'Test',TAB_Lead_Owner__c = 'Test14',Seat_Letter_Sent__c=System.today());
       insert OLead1;
      
       Lead OLead2 = new Lead(Status = '2-Invitation Letter Sent', LastName = 'Test4', Company = 'Test',TAB_Lead_Owner__c = 'Test14',Seat_Letter_Sent__c=System.today());
       insert OLead2;

                    
       CampaignMember cCampaignMember = new CampaignMember(CampaignId=OCampaign.Id, LeadId=OLead.Id,Status='Sent');
       Insert cCampaignMember ;
      
       CampaignMember cCampaignMember1 = new CampaignMember(CampaignId=OCampaign.Id, LeadId=OLead1.Id,Status='Sent');
       Insert cCampaignMember1 ;
      
       CampaignMember cCampaignMember2 = new CampaignMember(CampaignId=OCampaign.Id, LeadId=OLead2.Id,Status='Sent');
       Insert cCampaignMember2 ;

      
       List<CampaignMember> exCampaignMember=[Select LeadId from CampaignMember Where CampaignId = :OCampaign.Id];
       
       Lead lLead1 = [Select TAB_Lead_Owner__c,Id,Seat_Letter_Sent__c From Lead where Id = :OLead.Id];
       lLead1.Seat_Letter_Sent__c =System.today();
       update lLead1;
      
        Lead lLead2 = [Select TAB_Lead_Owner__c,Id,Seat_Letter_Sent__c From Lead where Id = :OLead1.Id];
        lLead2.Seat_Letter_Sent__c =System.today();
        update lLead2;

      
     }
}

 

 

can anyone help me on this, to improve the Test Coverage percentage to 75%. where i need to move this to production server.

 

i appreciate your help.

 

 

 

Thanks.