@TextToNumber Decimal Warning

If you run this formula in traditional Domino

@Text(@TextToNumber(“20,40”)*2)

You will get 80,40 back into the field

But if you run this in some XPage Code you will get

0

Why is this you might ask, well probably because javascript do not recognize comma as a decimal delimiter

So you need to change the formula to this.

@Text(@TextToNumber(@ReplaceSubstring(“20,40″,”,”,”.”))*2)

Then you will get 40,8 back. Not that when you do @Text() on the number the comma is back 😉

  1. problem could be – cuz you run
    @Text(@TextToNumber(“20,40″)*2) – on Local PC so it uses your local delimiter
    test with xPage can be tested on Server and server has different delimiter.

    so you can really try to do is next (I do not test just use logic)
    delimiter:=@text(1/10)
    as result delimiter will keep 0.1 or 0,1 depends of you system settings. then just cut second char and it will be your system delimiter.

  2. thank you, i used this in my code today. very helpful

Leave a Comment


NOTE - You can use these HTML tags and attributes:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>