Skip to main content
Participant
August 17, 2018
Answered

Tools > Action Wizard JavaScript

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!

This topic is closed to new replies. Start a new post to keep the conversation going.
George_JohnsonCorrect answer
Inspiring
August 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\"));");

9 replies

try67
Community Expert
Community Expert
August 17, 2018

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

this.calculateNow();

Translate
Participant
August 17, 2018

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?

Translate
try67
Community Expert
Community Expert
August 17, 2018

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.

Translate
Inspiring
August 17, 2018

Did you add a Save step?

Translate
Participant
August 17, 2018

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

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

f.value = 100;

Translate
Inspiring
August 17, 2018

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?

Translate