function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Abhirams470Abhirams470 

: 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
Sagarika RoutSagarika Rout
I think you have missed out  the starting position of string .
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;
Ramu_SFDCRamu_SFDC
Hi, 

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();
Abhirams470Abhirams470
Hi thanks a lot.problem is solved.appreciate your help.