Skip to main content
Participant
October 9, 2019
Answered

Javascript doesnt run from Button action

  • October 9, 2019
  • 2 replies
  • 877 views

Hi everybody,

 

I have the feeling my problem should be simple to solve but I cant figure it out. I am very new to this .. so I might be absolutley on the wrong track.

 

I have two PDF forms: A0.pdf and A1.pdf. The user should fill the template A0.pdf and if required afterwards also the additional template A1.pdf. As there are form fields containing the same information in both forms, I would like to transfer the mutual data from the A0.pdf to the A1.pdf . My idea was to use a button in the A0.pdf that if pressed opens an empty template of the A1.pdf and then fills in the data. Here is what I came up with so far as an example for one Name field:

 

 

var v = this.getField("A0-Name1");
var myDoc = app.openDoc({cPath: "/C/UserData/user/Documents/A1-template.pdf", bHidden: false});
myDoc.getField("A1-Name1").value = v.value;

 

 

The script works when I run it from the console. But when I trigger it trough the action of my button the following error is returned:

 

 

TypeError: myDoc is undefined
3:AcroForm:A1button:Annot1:MouseUp:Action1

 

 

can anyone help or has a different solution to my problem?

 

Thank you very much 🙂

 

Tullius

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

Set the property disclosed of the document.

2 replies

Bernd Alheit
Community Expert
Bernd AlheitCommunity ExpertCorrect answer
Community Expert
October 14, 2019

Set the property disclosed of the document.

Participant
October 14, 2019
That was the solution! thank you very much 🙂
ls_rbls
Community Expert
Community Expert
October 14, 2019

Hi,

 

Is that supposed to be a document level script?

 

Where are you placing the code?