#Forms I'm using the following JavaScript to calculate a number in my form:

#Forms I'm using the following JavaScript to calculate a number in my form:
window.FormAPI.setValue('number10', (window.FormAPI.getValue("number8").id * window.FormAPI.getValue("radio9").id));
The value needs to be displayed with 2 decimal places 0.89 instead of 0.89999999. The value is calculated dynamically on the form. Is there a way I can do this in Appian v6.6.1 using JavaScript?
I tried FormAPI.setFormatValue('text11',(window.FormAPI.getValue("text11").id),#.##); on the event rules (load) for the form, and I'm getting an exception error. Thanks......

OriginalPostID-85278

OriginalPostID-85278

  Discussion posts and replies are publicly visible

Parents
  • Going back to your original code here's how you can do it using the JavaScript native Math.round() function:

    var operandOne = window.FormAPI.getValue("number8").id;
    var operandTwo = window.FormAPI.getValue("radio9").id;
    window.FormAPI.setValue('number10',Math.round(operandOne * operandTwo * 100) / 100 );

    Here's an example you can test with, just import this form in any model and test by typing something on number8, then selecting a value in cto see how number10 gets the result of rounding number8*radio9 to two decimals forum.appian.com/.../108750
Reply
  • Going back to your original code here's how you can do it using the JavaScript native Math.round() function:

    var operandOne = window.FormAPI.getValue("number8").id;
    var operandTwo = window.FormAPI.getValue("radio9").id;
    window.FormAPI.setValue('number10',Math.round(operandOne * operandTwo * 100) / 100 );

    Here's an example you can test with, just import this form in any model and test by typing something on number8, then selecting a value in cto see how number10 gets the result of rounding number8*radio9 to two decimals forum.appian.com/.../108750
Children
No Data