Script example to set the number of digits after decimal point
By using a script within a calculated field, you can perform arithmetic operations that involve multiple fields in your form.
For instance, if you want to multiply fields 'A' and 'B', you can use this script:
While this script works and is valid, it is possible that multiplying numbers with decimals results in an infinite number of decimals. To avoid this, we can modify the function in the following way and limit the number of digits after the decimal point to 3.
If you want to set a different number of digits, just change the 3.
For instance, if you want to multiply fields 'A' and 'B', you can use this script:
Flokzu.getFieldValue([[A]]) * Flokzu.getFieldValue([[B]])
While this script works and is valid, it is possible that multiplying numbers with decimals results in an infinite number of decimals. To avoid this, we can modify the function in the following way and limit the number of digits after the decimal point to 3.
( Flokzu.getFieldValue([[A]]) * Flokzu.getFieldValue([[B]]) ).toFixed(3)
If you want to set a different number of digits, just change the 3.
Updated on: 25/10/2018
Thank you!