Insert multiple records using for using Apex #inSalesforce

Insert multiple records using for using Apex #inSalesforce


Insert Multiple Records Class:


public class insertMultipleTestRecordsClass{
public void testRecordsInsertionMethod(){
List<Candidate__c> cnd = new List<Candidate__c>();
Candidate__c c;
for(Integer i=20;i<=100;i++){
c = new Candidate__c(Name='sampleCandidate'+string.valueof(i),Country__c = 'abcd');
cnd.add(c);
}
insert cnd;
}
}



Test this from Anonymous Window of Developer Console 


insertMultipleTestRecordsClass x = new insertMultipleTestRecordsClass();
x.testRecordsInsertionMethod();

Comments