1 person found this helpful
There are two different ways to approach this: You can do the calculation and the field will still have the negative value, but via a custom formatting script, you are then changing the displayed value to 0.00. Or, you can create a custom calculation script that does both the calculation of the value, and the adjustment at the end in case the result is negative.
If you just want to do it the easy way, the custom formatting script will do the job:
if (Number(event.value) < 0) event.value = "0.00";
If you want to do all the calculations in a custom calculation script, the following will work (this is just an example, you will have to come up with your own calculation):
event.value = Number(this.getField("Text1").value) - Number(this.getField("Text2").value); if (event.value < 0) event.value = 0;
The formatting (e.g. "0.00") would be done via the "Format" tab on the field's properties dialog, where you would select a specific Number format.
what if it was a three step calculation
What exactly do you mean by that? How are you calculating your field value?
i got it to work, but is there a way for the outcome of text 1 to turn into a negative
You can do that by putting a 'minus' sign before the expression (e.g. "-this.getField("Text1").value" ). If you need more help with your script. please post your script here so that we know what exactly you are doing.
event.value = Number(this.getField("Text5").value) - Number(this.getField("fill_105").value) + Number(this.getField("fill_101").value)
how can i make it multiply by a negative
You can wrap the whole expression in "()" and then add a minus before that:
event.value = -(Number(this.getField("Text5").value) - Number(this.getField("fill_105").value) + Number(this.getField("fill_101").value));
you're a savior