Copy link to clipboard
Copied
I'm hoping someone can help me out with a validation script where the answer will round to 0. So, if the script results in an amount of $83,333.33, I'd the validation script to round this to 0 or in this case the answer would be $83,333.00. I have no idea how to write this one. this is where i'm stuck: if(event.value==
Thank you for any feedback on this one.
Copy link to clipboard
Copied
This is not very accurate. It should actually be:
/*your calculation goes here*/
event.value=Math.round(event.value);
Copy link to clipboard
Copied
Shouldn't it be a calculation script?
event.value=Math.round(/*your calculation goes here*/);
Copy link to clipboard
Copied
This doesn't work. I have a calculation script in place already. I want to validate the result of the script. Seems to me that i could do something like this to validate the result:
if(event.value>0)event.value=Math.round(/*event.value*/;
Copy link to clipboard
Copied
That won't work. The validate script runs before the calculation script. What is your calculation script?
Copy link to clipboard
Copied
You can use validate script, because when field value changes (due to calculation script) then validation script will trigger.
You could also input rounding directly into your calculate script.
What exactly are you trying to round, just decimals?
Copy link to clipboard
Copied
This is not very accurate. It should actually be:
/*your calculation goes here*/
event.value=Math.round(event.value);
Copy link to clipboard
Copied
2/3; //Your calculation
event.value=Math.round(event.value);
returns 0.00 (field formatted to 2 decimals).
event.value=Math.round(2/3);
returns 1.00 (0.66667 rounded)
Copy link to clipboard
Copied
This works perfectly!!! Thank you.