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

Tools > Action Wizard JavaScript

New Here ,
Aug 17, 2018 Aug 17, 2018

Copy link to clipboard

Copied

I have a list of pdf documents, all of them have "ABC" field which is a sum of fields Field1 and Field2. I need to change the rule and add one more filed to the sum.

I use Tools>Action Wizard and JavaScript like this:

var f = this.getField("ABC");

f.setAction('Calculate',  "AFSimple_Calculate(\"SUM\", \"Field1, Field2, Field3\");" );

But after applying the action to the docs nothing was changed. What am I doing wrong?

Thanks!

TOPICS
Acrobat SDK and JavaScript

Views

719

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

LEGEND , Aug 17, 2018 Aug 17, 2018

This code works as expected for me:

var f = this.getField("ABC");

f.setAction("Calculate", "AFSimple_Calculate(\"SUM\", new Array(\"Field1\", \"Field2\", \"Field3\"));");

Votes

Translate

Translate
LEGEND ,
Aug 17, 2018 Aug 17, 2018

Copy link to clipboard

Copied

Did you add a Save step?

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 ,
Aug 17, 2018 Aug 17, 2018

Copy link to clipboard

Copied

Sure, I did. For instance, this code works OK

var f = this.getField("GELEOtherClothing");

f.value = 100;

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
LEGEND ,
Aug 17, 2018 Aug 17, 2018

Copy link to clipboard

Copied

It seems to apply the script, but it's not reflected in the calculate tab of the field properties dialog as you would expect. Is the calculation being performed correctly for you?

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 ,
Aug 17, 2018 Aug 17, 2018

Copy link to clipboard

Copied

The fields are blank, they are to be populated by users. I added some test values and the calculation performed correctly. But this is not what I need. I need to change the filed properties. Our designer made a mistake, he missed some fileds to be sum up. More that 50 copies of the document was created and all of them have the same issue of course. I would like to write a script to fix all the documents using Tools>Action Wizard instead of fixing each document manually. Is it possible?

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
LEGEND ,
Aug 17, 2018 Aug 17, 2018

Copy link to clipboard

Copied

This code works as expected for me:

var f = this.getField("ABC");

f.setAction("Calculate", "AFSimple_Calculate(\"SUM\", new Array(\"Field1\", \"Field2\", \"Field3\"));");

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 ,
Aug 17, 2018 Aug 17, 2018

Copy link to clipboard

Copied

LATEST

Thanks! George_Johnson code works OK!

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 ,
Aug 17, 2018 Aug 17, 2018

Copy link to clipboard

Copied

In addition to adding a Save step, add this line to the end of your code:

this.calculateNow();

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 ,
Aug 17, 2018 Aug 17, 2018

Copy link to clipboard

Copied

Thanks for your answer, but with this.calculateNow(); the result is the same, nothing was changed in the docs.

May be I wasnt clear. I dont need the field to be re-calculated on doing JavaScript, I need to change field's property, the list of fields to be sum up. Am I on the right way?

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 ,
Aug 17, 2018 Aug 17, 2018

Copy link to clipboard

Copied

You do need to perform a re-calculation, because just setting a new action to the field's Calculation event does not actually trigger it.

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