You need to sign in to do that
Don't have an account?
Anu-SFDC
Too Many Script Statements:200001
Hi, I have a managed package in my instance.. I have created a trigger in my sandbox instance.. But When I run the test classes it is showing too many scriot statements error.. Here is my code: trigger dateConvert on CnP__CnP_Transaction__c (before insert) { for(CnP__CnP_Transaction__c c:Trigger.new){ c.CnP__bSource__c = Integer.valueOf(c.CnP__bSource__c); if(c.CnP__bSource__c == 2 ){ String delimslash = '/'; String[] DDate; Datetime myDate; String tdate = c.Dummy_Field__c; if(tdate!=null){ String[] splitdate = tdate.split(' '); DDate = splitdate.get(0).split('/'); String TTime = splitdate.get(1); String month = DDate.get(0); String day = DDate.get(1); String year = DDate.get(2); String hour = TTime.split(':').get(0); String minute = TTime.split(':').get(1); String second = '00'; myDate = datetime.newInstance(integer.ValueOf(year),integer.ValueOf(month), integer.ValueOf(day), integer.ValueOf(hour), integer.ValueOf(minute), integer.ValueOf(second)); c.CnP__TransactionDate__c = myDate; c.CnP__TransactionTimeZone__c = myDate; } } } } Help me Regarding this. Anu
Sorry
It was the allignment problem
trigger dateConvert on CnP__CnP_Transaction__c (before insert) {
for(CnP__CnP_Transaction__c c:Trigger.new){
c.CnP__bSource__c = Integer.valueOf(c.CnP__bSource__c);
if(c.CnP__bSource__c == 2){
c.CnP__TotalCharged__c = c.CnP__Amount__c;
c.CnP__TotalDue__c = c.CnP__Amount__c;
c.CnP__Organization_Name__c = c.CnP__Last_Name__c;
String delimslash = '/';
String[] DDate;
Datetime myDate;
String tdate = c.Dummy_Field__c;
if(tdate!=null){
String[] splitdate = tdate.split(' ');
DDate = splitdate.get(0).split('/');
String TTime = splitdate.get(1);
String month = DDate.get(0);
String day = DDate.get(1);
String year = DDate.get(2);
String hour = TTime.split(':').get(0);
String minute = TTime.split(':').get(1);
String second = '00';
myDate = datetime.newInstance(integer.ValueOf(year),integer.ValueOf(month), integer.ValueOf(day),integer.ValueOf(hour), integer.ValueOf(minute), integer.ValueOf(second));
c.CnP__TransactionDate__c = myDate;
c.CnP__TransactionTimeZone__c = myDate;
}
}
}
}
Minor comments about this trigger...
Ultimately, it's a basic need for optimizations across ALL code that runs when those objects are being modified. Just because the execution fails in this trigger doesn't necessarily mean that this trigger is the offender. Yes, this trigger can gain something from optimizations, but even with 200 records ( the maximum batch size ) this trigger can only contribute up to 8000 lines out of 200000.
There's a lot more investigation to be done, such as what other related records get updated from the original object, and see what kinds of triggers fire from those, etc etc.