Error occurring on PC Adobe Reader 2017, but functioning on Mac Adobe Acrobat DC
I have pieced together Javascript to validate that required forms are filled, if filled, prompt a save as with new name suggestion, and then email submission. It functions properly on Mac Adobe Acrobat Pro DC, but on Windows 10 Adobe Reader 2017, I received on the Javascript debugger "TypeError: f is null 7:Field:Mouse Down"
I have it set on a submit button, Mouse Down, run a JavaScript. It may look pretty messy as I am very novice to this!
Any idea why this would be happening from the script below?
var emptyFields = [];
for (var i=0; i<this.numFields; i++) {
var f= this.getField(this.getNthFieldName(i));
if (f.type!="button" && f.required && f.display==display.visible) {
if ((f.type=="text" && f.value=="" && f.value !== 0) || (f.type=="checkbox" && f.value=="Off")) emptyFields.push(f.name);
}
}
if (emptyFields.length>0) {
app.alert("At least one required field was empty. Fill out the required fields before saving:\n" + emptyFields.join("\n"));
} else {
var newFileName =
("TheFeed_DigitalContentBrief_") +
this.getField("Brand").valueAsString + "_" + this.getField("Market").valueAsString + "_" + this.getField("BriefingDate").valueAsString + ".pdf";
app.response("Please copy the text below and use it as the new file-name:","", newFileName);
app.execMenuItem("SaveAs");
this.mailDoc({bUI:false,cTo:"General - TEAMS: The Feed LATAM <042c8d45.nestle.onmicrosoft.com@emea.teams.ms>",cSubject:"New Content Brief from " + this.getField("Market").value + " for " + this.getField("Brand").value, cBody:"Attached new Digital Content Brief, please review."})
}
