function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Ankit SinghalAnkit Singhal 

Insert list of tasks having around 50000 records.

Hi Guys,

 

I have a scenario where I am collecting tasks in a list.

Now the size of this list can exceed 50000.

 

How can i insert this list containing task Records into database .

Since the maximum size of DML is 10000 using list,thats why Insert will fail if list size exceed 10k.

I also want to send an email to user once the Insert is succesfull.

 

Sample code

List<SMP_Step__c> SMPSteps=new List<SMP_Step__c>();

SMP_Step__c temp=new SMP_Step__c(name='AnkitTest',Step_Name__c='tasktestbatch',Step_Type__c='Task',SMP_Template__c='a0PU0000001eX12');
for(Integer i=1;i<=50000;i++)
{
    SMPSteps.add(temp);
 
}

Now this List SMPSteps has 50000 records ,so how to proceed in this type of scenario.

Plz help.

Alex.AcostaAlex.Acosta

Break it up into small chunks. You're allowed 150 DML statements.

 

Total number of DML statements issued2150

 

http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_gov_limits.htm