I'm trying to convert String
to Integer
datatype. But I'm unable to convert. I know its simple, but getting me problem here.
It giving me below error
FATAL_ERROR|System.TypeException: Invalid integer:
trigger
trigger CreatePckdDime on Package__c (after update) {
List<String> len = new List<String>();
List<String> wdt= new List<String>();
List<String> hgt= new List<String>();
List<String> cnt = new List<String>();
List<Package_Dimension__c> updPkgDim = new List<Package_Dimension__c>();
for(Package__c p : trigger.New)
{
len.add(p.CSV_Length__c);
wdt.add(p.CSV_Width__c);
hgt.add(p.CSV_Height__c);
cnt.add(p.CSV_Count__c);
}
string height;
string width;
string length;
string count;
for(Integer i=0; i<len.size();i++)
{
for( integer j = 0; j < 20; j++ )
{
height = hgt[i].substring(j*3,3);
length = len[i].substring(j*3,3);
width = wdt[i].substring(j*3,3);
count = cnt[i].substring(j*4,4);
System.debug('@@@'+Integer.valueOf(height)); // this giving error
System.debug('@@@'+Double.valueOf(height)); // this is also not wokring
//I'm getting value in height 000 in string format.
//I'm trying to compare like
if(height == '000') // this statement executing always false even if value in height is 000.
{
}
}
}
}
I'm getting value for height is 000 in string format at some situation.
I'm trying to compare like
if(height == '000') // this statement executing always false even if value for height is 000.
{
}
Can you please help me to solve my problem.
Edited Part:
This part creating the problem but why substring is giving null value.
example
string a='1234567890';
System.debug('@@@a'+a.substring(0,3));
System.debug('@@@b'+a.substring(3,3));
output
14:53:41:004 USER_DEBUG [2]|DEBUG|@@@a123
14:53:41:004 USER_DEBUG [3]|DEBUG|@@@b //here getting null value thus its unable to convert into integer.