Skip to main content
Known Participant
May 19, 2023
Answered

Document Javascript works in Acrobat, but not in Reader when called as a function from fields

  • May 19, 2023
  • 2 replies
  • 1541 views

I have a series of fields that are set to remain hidden until a particular calculating field's value goes above zero. I have a script at the document level that is called from the series of fields as a function in Custom calculation script (see below.) This works great in Acrobat but not in Reader. If I modify it where the script is directly in each field, it works in Reader. I use Adobe Acrobat 2020 and Adobe Acrobat DC Reader. I have attached the file.

 

function unhideFields() {

   var a = this.getField("txtAdjustmentAmt");
   var f = event.target;

   if (a.value > 0)  
   {
       f.display = display.visible;
   }
   else if (a.value <= 0)
   {
       f.display = display.hidden;
   }
}

Thank you,

 

Teagan

This topic has been closed for replies.
Correct answer Bernd Alheit

Check the Javascript console for errors. 

You will get an error message in Acrobat Reader at:

  this.setAction("WillClose", myWillClose);

And the function unhideFields will not defined.

 

2 replies

Bernd Alheit
Community Expert
Bernd AlheitCommunity ExpertCorrect answer
Community Expert
May 20, 2023

Check the Javascript console for errors. 

You will get an error message in Acrobat Reader at:

  this.setAction("WillClose", myWillClose);

And the function unhideFields will not defined.

 

try67
Community Expert
Community Expert
May 20, 2023

I was going to try and help you, but then you went and changed my default highlighting color to your own, without notifying me of the change or asking my permission for doing so, so now I'm not going to bother. I strongly recommend you don't do such things to your users!

try67
Community Expert
Community Expert
May 20, 2023

For anyone who fell into the same trap as me, run this code to revert back to the original color:

app.runtimeHighlightColor = ["RGB",0.8000030517578125,0.8431396484375,1];