Options

Unable to write decimals in quantity

marvinqmarvinq Member Posts: 69
edited 2011-01-21 in NAV Three Tier
Hi,

I have got a mysterious problem.

I have made a asp.net site which creates sales orders and lines in NAV. Everything works just perfect, until I tried to use decimals in my quantity. When decimals are used I get the message that the input string is not i the correct format.

My site is pretty much like this one:
http://blogs.msdn.com/b/freddyk/archive ... d-rtm.aspx

If I replace the following line I get the error...

line1.Quantity = 3;

replaced by:

line1.Quantity = decimal.Parse(tbQuantity.Text);

I have also tried in a more static way, to debug..

line1.Quantity = 3.3m;

..this just sets quantity to 33.

Why?? What is wrong?

Comments

  • Options
    SogSog Member Posts: 1,023
    This is due to country-specific decimal notation.
    I presume Denmark has a decimal notation similar to the Belgian one. With "." for seperation of thousands and "," for seperation of decimals.
    It is best to save your send your quantity through as text and evaluate it with a decimal before putting it in the quantity field of your order.

    a handy line of code is available for the conversion variables to replace are in []:
    [MyparsableString] := CONVERTSTR([YourQuantityString],'.',DELCHR(FORMAT(0.1),'=','01')))
    This part will get the country-specific decimal seperator: DELCHR(FORMAT(0.1),'=','01')
    It will replace it with a '.' which in C/AL is always the decimal seperator
    |Pressing F1 is so much faster than opening your browser|
    |To-Increase|
Sign In or Register to comment.