script writing help, multiple text boxes and if/than parameter
the below script breaks every time at the this.getfield command. Rank and Abbreviated rank are list boxes. I am trying to run this InDesign and willing to push it to acrobat but dont know if that would work either.
// Get references to the required fields
var rankField = this.getField("Rank");
var firstField = this.getField("First");
var lastField = this.getField("Last");
var dutyTitleField = this.getField("Duty Title");
var unitField = this.getField("Unit");
var inputField = this.getField("input");
var decField = this.getField("dec");
var abbreviatedRankField = this.getField("Abbreviated Rank");
// Check the values of the checkboxes
var longCheckbox = this.getField("long").value;
var shortCheckbox = this.getField("short").value;
// Get the values from the input fields
var rank = rankField.valueAsString;
var first = firstField.value;
var last = lastField.value;
var dutyTitle = dutyTitleField.value;
var unit = unitField.value;
var input = inputField.value;
var abbreviatedRank = abbreviatedRankField.valueAsString;
// Build the output based on the checkbox values
var output = "";
if (longCheckbox === "Yes") {
output = rank + " " + first + " " + last + " distinguished " + (firstField.value === "female" ? "herself" : "himself") + " by meritorious service as " + dutyTitle + ", " + unit + ".";
} else if (shortCheckbox === "Yes") {
output = rank + " " + first + " " + last + " distinguished " + (firstField.value === "female" ? "herself" : "himself") + " by meritorious service while assigned to " + unit + ".";
}
// Set the value of the 'dec' field
decField.value = output;
// Build and set the closing phrase
var closingPhrase = "The distinctive accomplishments of " + abbreviatedRank + " " + last + " reflects credit upon " + (firstField.value === "female" ? "herself" : "himself") + " and the United States Air Force.";
this.getField("closingPhrase").value = closingPhrase;
