I have a three tier discount level requirement which I have encoded as follows:
var numTotalUnits = xfa.resolveNode("subTotal.numTotalUnits");
var numThreshold1 = xfa.resolveNode("this.parent.parent.parent.subControls.subVolume.numThreshold1");
var numThreshold2 = xfa.resolveNode("this.parent.parent.parent.subControls.subVolume.numThreshold2");
var numThreshold3 = xfa.resolveNode("this.parent.parent.parent.subControls.subVolume.numThreshold3");
var numRegularPrice = xfa.resolveNode("this.parent.parent.parent.subControls.subBelow.numRegularPrice");
var numDiscount1 = xfa.resolveNode("this.parent.parent.parent.subControls.subVolume.numDiscount1");
var numDiscount2 = xfa.resolveNode("this.parent.parent.parent.subControls.subVolume.numDiscount2");
var numDiscount3 = xfa.resolveNode("this.parent.parent.parent.subControls.subVolume.numDiscount3");
if (numTotalUnits.rawValue == null || numTotalUnits.rawValue == ""){
this.rawValue = numRegularPrice.rawValue;
}
else if (numThreshold1.rawValue != null && numDiscount1.rawValue != null && (numThreshold2.rawValue == null || numThreshold2.rawValue == "") && (numDiscount2.rawValue == null || numDiscount2.rawValue == "") && (numTotalUnits.rawValue < numThreshold1.rawValue)){
this.rawValue = numRegularPrice.rawValue;
}
else if (numThreshold1.rawValue != null && numDiscount1.rawValue != null && (numThreshold2.rawValue == null || numThreshold2.rawValue == "") && (numDiscount2.rawValue == null || numDiscount2.rawValue == "") && (numTotalUnits.rawValue >= numThreshold1.rawValue)){
this.rawValue = numDiscount1.rawValue;
}
else if (numThreshold1.rawValue != null && numDiscount1.rawValue != null && numThreshold2.rawValue != null && numDiscount2.rawValue != null && (numThreshold3.rawValue == null || numThreshold3.rawValue == "") && (numDiscount3.rawValue == null || numDiscount3.rawValue == "") && (numTotalUnits.rawValue >= numThreshold1.rawValue && numTotalUnits.rawValue < numThreshold2.rawValue)){
this.rawVaue = numDiscount1.rawValue;
}
else if (numThreshold1.rawValue != null && numDiscount1.rawValue != null && numThreshold2.rawValue != null && numDiscount2.rawValue != null && (numThreshold3.rawValue == null || numThreshold3.rawValue == "") && (numDiscount3.rawValue == null || numDiscount3.rawValue == "") && (numTotalUnits.rawValue >= numThreshold2.rawValue)){
this.rawValue = numDiscount2.rawValue;
}
else if (numThreshold1.rawValue != null && numDiscount1.rawValue != null && numThreshold2.rawValue != null && numDiscount2.rawValue != null && numThreshold3.rawValue != null && numDiscount3.rawValue != null && (numTotalUnits.rawValue >= numThreshold2.rawValue && numTotalUnits.rawValue < numThreshold3.rawValue)){
this.rawValue = numDiscount2.rawValue;
}
else if (numThreshold1.rawValue != null && numDiscount1.rawValue != null && numThreshold2.rawValue != null && numDiscount2.rawValue != null && numThreshold3.rawValue != null && numDiscount3.rawValue != null && (numTotalUnits.rawValue >= numThreshold3.rawValue)){
this.rawValue = numDiscount3.rawValue;
}
When the total order value is over the third discount level and is reduced to the second all works fine, however, when the total is reduced to the first level or below that the code does not copy over the first discount level or the regular price. All else works fine.
Please provide any assistance as any is extremely welcome. Previously BR001 had helped with the initial coding, however, it did not work when discount levels were not filled.
Lewis