Question
Adobe Form Custom Calculation Script
Having an issue with script for a custom calculation.
I need to take number from a field and search through 323 fields to find a matching number, then search through 323 percentage fields and pull the matching field number percent value.
This code worked on a small sample that I input, but is not working with my actual program:
var target = this.getField("TargetNumberField").value; // The number you are searching for
var found = false;
var result = 0;
// Loop through 323 fields (assuming named Lookup1, Lookup2... or similar)
for (var i = 1; i <= 323; i++) {
if (this.getField("Lookup" + i).value == target) {
// Match found, get corresponding percentage field
result = this.getField("Percent" + i).value;
found = true;
break; // Stop loop
}
}
Any and all help is greatly appreciated!
if (found) {
event.value = result;
} else {
event.value = ""; // Or 0 if no match
}