Appian Community and Appian Academy are being upgraded. From July 24–August 3, the Appian Community will be in read-only mode. During this time, the site will be read-only and user registration will be disabled. We apologize for any inconvenience this may cause, but a more secure, stable, and performant Community experience is coming soon!

The new Appian Community launches August 3, followed by Appian Academy on August 7. During the migration, Appian Community Edition, Appian Academy, Documentation, Certifications, Instructor-led Customer Training, Partner Sales Training & Accreditation, and Forum (for Appian Partners and Customers only) will remain available.

#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