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
Rony57Rony57 

Visual force Error-System.TypeException: Invalid decimal

Hello All,
            I have written code in apex and visualforce  to saving the Geo location in my detail page. While doing this an error is coming on this particular line.It throw an error on my particular this code:
 
newSupply.GeoLocation__Latitude__s=decimal.valueOf(latitude);
newSupply.GeoLocation__Longitude__s=decimal.valueOf(longitude);
"Visualforce Error System.Type Exception: Invalid decimal".
 
sandeep sankhlasandeep sankhla
Hi Anurag,

A common problem would be leading white space, try using trim()..try this and let me know if this not solves your issue..

P.S. If my answer helps you to solve your problem please mark it as best answer. It will help other to find best answer.

Thanks,
Sandeep
Salesforce Certified Developer 
Rony57Rony57
@sandeep  I had tried  newSupply.GeoLocation__Latitude__s=decimal.valueOf(latitude.trin()); But  the error is sames to same.
Rony57Rony57
@Hi Mudasir,
                   In the action {!saveProperty} i have written a code   so that after save the property it should render into next page .

 
public PageReference saveProperty() {
     PageReference pg = Page.matchePage;
     return pg;
}

its  haiving the decimal error same.
ManojjenaManojjena
Hey Anurag,
Please check null value of lattitue, In case any null value is passing to the Decimal.valueOf function will throw you the TypeException .
 
Tyler McCartyTyler McCarty
Hi, 

My problem came from trying to read from excel file. The last line would always give an error whether it was a decimal, integer, or date. I did not test with string but what I did was add an additional column to the excel file and it worked fine. Has something to do with how apex is parsing the end of line.