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

Javascript doesnt run from Button action

New Here ,
Oct 09, 2019 Oct 09, 2019

Copy link to clipboard

Copied

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

TOPICS
Acrobat SDK and JavaScript

Views

517

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 , Oct 13, 2019 Oct 13, 2019

Set the property disclosed of the document.

Votes

Translate

Translate
Community Expert ,
Oct 13, 2019 Oct 13, 2019

Copy link to clipboard

Copied

Hi,

 

Is that supposed to be a document level script?

 

Where are you placing the code?

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 ,
Oct 13, 2019 Oct 13, 2019

Copy link to clipboard

Copied

Set the property disclosed of the document.

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 ,
Oct 13, 2019 Oct 13, 2019

Copy link to clipboard

Copied

LATEST
That was the solution! thank you very much 🙂

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