How to convert Text from a text field into number type in calculation field by javascript ?

Comments

11 comments

  • 杜晓闻

    It is very important that I use the feature to achieve a little bit complex function to handle orders and invoices .I hope we can make it done .

    Best

    JianWen

    2
    Comment actions Permalink
  • Andreas Haugstrup Pedersen

    Once a calculation field has been created its return type is locked. In your case it looks like you have created a calculation field that returns a string and now you're trying to return a number.

    Remove your current calculation field and create a new one that returns a number from the start.

    /Andreas

    0
    Comment actions Permalink
  • 杜晓闻

    Hi Andreas,

    Thank you very much. It works.

    Best regards

    JianWen

    0
    Comment actions Permalink
  • 杜晓闻

    Hi ,
    I met the same situation as your instruction .That means it worked in some calculation fields ,but some fields don't work .
    please refer the screen shot :https://drive.google.com/file/d/0B3JEgK0GXrSSZ205Q2J4Wjl2clk/edit?usp=sharing

    I am not sure if it's the result from function :"parseFloat" ? but it does work in my previous fields.

    Best

    JianWen

    1
    Comment actions Permalink
  • Andreas Haugstrup Pedersen

    You are probably ending up with NaN as a value for sum at some point or for some items.

    0
    Comment actions Permalink
  • 杜晓闻

    I'm sure "ar[i]" in the pic is a number("1","2" or "3")(not NaN), and this code works well under node.js, Can you tell me why it shows "the result is not a valid number"?

    Best

    JianWen

    0
    Comment actions Permalink
  • 杜晓闻

    The issue seems result from the semicolon in the end . When I deleted the semicolon ,just :"sum",instead of :"sum;",It works and shows the right sum result.

    1
    Comment actions Permalink
  • Fritz Feger

    I've not been able to solve the issue. And yes, I'm sure the calculation field is a numbers field, since when I remove the string and the parsing everything works fine again.

    Here's a screenshot: https://www.dropbox.com/s/54lz50j62taregu/Screenshot%202015-01-16%2022.55.14.png?dl=0

    Best, Fritz

    0
    Comment actions Permalink
  • 杜晓闻

    Did you try to add a semicolon ";" or a space " "at end ? That it "Number " or "Number;",or "Number; " or "Number ;"

    0
    Comment actions Permalink
  • Fritz Feger

    杜晓闻, I've tried all four possible combinations from blank space and semicolon. Always the same result.

    0
    Comment actions Permalink
  • 杜晓闻

    I checked my notes :It was number field and all right when it's "profit;"in the last line ,but later (maybe a few days later ),it showed "the result is not a valid number", then I tried a lot ,but it only worked as "profit" (deleted the semicolon ).
    good luck

    0
    Comment actions Permalink

Please sign in to leave a comment.

Powered by Zendesk