How to bulk create records using Salesforce Apex?

How to bulk create records using Salesforce Apex?

Salesforce Apex can be used to bulk create multiple or mass records.

Sample Code:

List < Case > listCases =
    new List < Case >();

for ( 
    Integer i = 1;
    i <=100;
    i++
) {
    
    listCases.add(
    	new Case(
        	Subject = 'Testing ' + i,
            Description = 'Test ' + i,
            Status = 'New',
            Origin = 'Email',
            Priority = 'Low'
        )
    );        
    
}

insert listCases;

Leave a Reply