As per this documentation Trigger
Note that static variable values are reset between API batches, but governor limits are not. Do not use static variables to track state information between API batches
I have this trigger
trigger apextrigger on Account (before insert) {
system.debug('Counter is'+ myclassfortrigger.incrementcounter());
system.debug(Trigger.new.size()+'MYTriggernew');
}
and class
public class myclassfortrigger{
public static integer counter = 0;
public static integer incrementcounter()
{
counter = counter + 1;
return counter;
}
}
when i pass say 500 record to this,via Dataloader,Bulk api enabled and batch size is made as 500
In my debug log i can see one log for this(as expected) and inside in my debug statements i could see static variables are not getting reset
it shows
16:17:39.128 (128115231)|USER_DEBUG|[3]|DEBUG|Counter is1 16:17:40.795 (1795145037)|USER_DEBUG|[3]|DEBUG|Counter is2
As it uses API batches i thought as per documentation static variables would have got reset?
Where am i going worng?