You need to sign in to do that
Don't have an account?
james7630
String with $ sign and commas causes failure
I have a string that is a currency from excel and im importing it into salesforce into a currency field. It fails on bigger numbers that have a comma, I am trying to remove the $ and the commas but it doesnt work.
for(String fi: row)
{
Decimal di = 0.0;
if(fi.contains('$'))
{
fi = fi.trim();
fi = fi.replace(',','');
fi = fi.replace('$','');
di = Double.valueOf(fi);
}
error
Caused by: System.TypeException: Invalid double: "$6546456 "
solution, remove the double quotes..
for(String fi: row)
{
Decimal di = 0.0;
if(fi.contains('$'))
{
fi = fi.remove('$');
fi = fi.remove(',');
fi = fi.remove('"');
di = Double.valueOf(fi);
}