You need to sign in to do that
Don't have an account?

: execution of BeforeInsert, caused by: System.StringException: Starting position out of bounds: 3
String state_var=l.STATE__c!=null?l.STATE__c.substring(3):'';
system.debug(LoggingLevel.ERROR,'state='+state_var);
l.STATE__c=state_var;
when iam trying to insert records using data loader
getting this error, : execution of BeforeInsert
caused by: System.StringException: Starting position out of bounds: 3
appreciate for your help in advance
system.debug(LoggingLevel.ERROR,'state='+state_var);
l.STATE__c=state_var;
when iam trying to insert records using data loader
getting this error, : execution of BeforeInsert
caused by: System.StringException: Starting position out of bounds: 3
appreciate for your help in advance
this should be
String state_var=l.STATE__c!=null?l.STATE__c.substring(0,3):'';
system.debug(LoggingLevel.ERROR,'state='+state_var);
l.STATE__c=state_var;
I noticed that you are just checking if the State field is null. Please also check if the length of the State__c field value is greater than 3 before taking the substring of 3 characters. Hope this helps. eg : Integer length= State__c.length();