Hello again, I have noticed a lot of people ask questions on how to calculate percentages easily and correctly. I recently made an invoice template that if you want to offer a discount - say 5% or 37% of the subtotal i will quickly calculate it.
Subtotal is calculated (Just a FormCalc calculation of line item totals). Discount is editable, not calculated. Both are set to display currency.
I have 3 fields (Numeric)
Subtotal, Discount & DiscountPercent
CHANGE EVENT- DiscountPercent (2 digits, no decimal, Display Pattern is num{z9})
// This code just ensures only 2 digits can be typed in the numeric field
if (xfa.event.newText.length > 2) {
xfa.event.change = "";
}
EXIT EVENT - DiscountPercent
// This will populate the Discount Field on exit with the discount percentage applied to the Subtotal.
Discount.rawValue = Subtotal.rawValue * 0.01 * this.editValue
- Adam