Calculations not working in after template pages are added

New Here ,
Mar 15, 2021 Mar 15, 2021

Copy link to clipboard

Copied

I have a document that is 4 pages long. On several pages I have checkboxes that are assigned an export value. After selecting the checkbox(s), the sum is then calculated at the bottom of the page, as pictured below.

 

Elliot5ECF_0-1615818786377.png

 

In addition to the 4 pages, I have hidden templates inside the document that populate at the press of a button. The script for that is posted below.

 

( var a = this.getTemplate("Additional Locations");a.spawn(); )

 

Here's the problem; when a new template page is added, the value box at the bottom of that particular page does not calculate the sum of the boxes checked on that page. The reason being (I think) the name field for checkboxes on the spawned template change from "CB1" to "P4.AdditionalSuspects.CB1"

 

Elliot5ECF_1-1615819309630.png

 

How can I fix this? 

 

TOPICS
JavaScript, PDF forms

Views

91

Likes

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

Adobe Community Professional , Mar 15, 2021 Mar 15, 2021
Use false for the rename parameter: a.spawn(this.numPages, false, false);

Likes

Translate

Translate
Adobe Community Professional ,
Mar 15, 2021 Mar 15, 2021

Copy link to clipboard

Copied

Use false for the rename parameter:

a.spawn(this.numPages, false, false);

Likes

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 ,
Mar 15, 2021 Mar 15, 2021

Copy link to clipboard

Copied

LATEST

This worked! Thank you for the fast reply! Now, this brings on another issue. The first spawned page works great, however, if I spawn another page, all of the form fields in the first spawned page are linked to the second spawned page. Is there a way to fix this?

Likes

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
Most Valuable Participant ,
Mar 15, 2021 Mar 15, 2021

Copy link to clipboard

Copied

You will need to convert the calculation to a script, and write in that script in a way that takes this into account.

Since the field names on the spawned pages are predictable and consistent with each other this can be done using some string manipulations, based on the name of the calculated field.

Likes

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