+ Start a Discussion
SurpriseSurprise 

Trigger On Custom object

Hi friends,

 

Will the below given code handle multiple records inserted from data loader.? If i insert one record from salesforce user interface trigger.new wil have one reocord probably stored at index zero and then it passes to the list of type book__c variable books andf record get stored at the zero index in the books variable..

 

 

Now if I use data loader ,keeping the same code as it is .I insert 20 records.How will this code behave? .Will all the records be stored in trigger.new variable at different index starting from 0,1,2..........19  and then same records will be asisgned to the book varible ,First records from trigger.new will be strored at index 0 in the book variable and record number 2 from trigger.new variable will be stored at index 1 of the book variable.Am I thinking  right ?can somebody validate?

 

trigger HelloWorld12 on Book__c(before insert)
{

Book__c[]books=trigger.new;
MyHelloWorld1.applydiscount(books);

}

sfdcfoxsfdcfox
You are correct. Up to 200 records will appear in Trigger.new (but this may be subject to change, so do not depend on this number). Regardless, the elements will range from 0 to List<Book__c> size()-1.