• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

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

New Here ,
Jun 26, 2019 Jun 26, 2019

Copy link to clipboard

Copied

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

}

TOPICS
Acrobat SDK and JavaScript , Windows

Views

482

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Jun 27, 2019 Jun 27, 2019

After this line:

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

Add this:

if (f==null) continue;

Votes

Translate

Translate
Community Expert ,
Jun 27, 2019 Jun 27, 2019

Copy link to clipboard

Copied

After this line:

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

Add this:

if (f==null) continue;

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 27, 2019 Jun 27, 2019

Copy link to clipboard

Copied

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?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 27, 2019 Jun 27, 2019

Copy link to clipboard

Copied

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)

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 27, 2019 Jun 27, 2019

Copy link to clipboard

Copied

Yes, that worked! I have been referencing your code pieces I've found to put this together! Thank you so much for your expertise!

One last question! Is there a way to stop the next function if the user hits cancel on the save window instead of continuing to submission?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 27, 2019 Jun 27, 2019

Copy link to clipboard

Copied

Only if it's a part of the same script, not if it's a separate command.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 27, 2019 Jun 27, 2019

Copy link to clipboard

Copied

LATEST

ok! Thank you for all of your help!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines