Skip to main content
hillaryl29753147
Participant
June 26, 2019
Answered

Error occurring on PC Adobe Reader 2017, but functioning on Mac Adobe Acrobat DC

  • June 26, 2019
  • 1 reply
  • 1089 views

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."})

}

This topic has been closed for replies.
Correct answer try67

After this line:

var f= this.getField(this.getNthFieldName(i));

Add this:

if (f==null) continue;

1 reply

try67
Community Expert
try67Community ExpertCorrect answer
Community Expert
June 27, 2019

After this line:

var f= this.getField(this.getNthFieldName(i));

Add this:

if (f==null) continue;

hillaryl29753147
Participant
June 27, 2019

Thank you so much!! It now works to continue the process for saving and submitting, but doesn't give notice for fields required being unfilled. Is there another way you know of coding this function?

try67
Community Expert
Community Expert
June 27, 2019

This code should work (I wrote it...), but change this line:

if ((f.type=="text" && f.value=="" && f.value !== 0) || (f.type=="checkbox" && f.value=="Off"))

To:

if (f.valueAsString==f.defaultValue)