I am creating an inventory form that has columns of Par, QOH and Amount to Order
P1 | Q1 | O1
P1 - Q1 = O1
Par # - Quantity on Hand # = Amount to order
If par is set at 6 and QOH is 4 we need to order 2. [6-4=2]
BUT, if par is set at 6 and QOH is 8 we do not need to place an order but the output is negative (-2). [6-8=(2)]
How do I make the output show zero when the calculation shows a negative answer?
As the custom calculation script of O1 use this code:
var p1 = Number(this.getField("P1").valueAsString); var q1 = Number(this.getField("Q1").valueAsString); event.value = Math.max(0, p1-q1);
Edit: Fixed a type-o in the code...