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

calculated fields (javascript) not updating when a page is deleted

Community Beginner ,
Sep 10, 2021 Sep 10, 2021

I have a summary page that shows some calculated fields and text that get their values from other pages (order forms). The 'order form' pages are spawned, and so a customer can create multiple orders (multiple pages) and can also delete a page. The javascript on the summary page is not updating if one of order form pages is deleted. Is their a script to refresh javascript if a page is deleted or something that would help?

TOPICS
How to , JavaScript , PDF forms
666
Translate
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 ,
Sep 10, 2021 Sep 10, 2021

this.calculateNow() ;

Translate
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 Beginner ,
Sep 10, 2021 Sep 10, 2021

I have tried this and it does not work. 

Translate
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 ,
Sep 10, 2021 Sep 10, 2021

Do you mind sharing your script?

Translate
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 Beginner ,
Sep 13, 2021 Sep 13, 2021

var strName;
var nSumEnrollmentFee = 0;
for(var i=0;i<this.numFields;i++)
{
strName = this.getNthFieldName(i);
if(/Enrollment_Fee$/.test(strName))
{
oFld = this.getField(strName);
if(oFld.page >=0)
nSumEnrollmentFee += oFld.value;
}
}
event.value=nSumEnrollmentFee;
this.calculateNow();

 

________________________-

 

I've tried using this.calculateNow(); both at the beginning and end of the script. When a page is deleted that this script gets information from, it does not update. 

Translate
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 ,
Sep 13, 2021 Sep 13, 2021

Use this.calculateNow(); after the page delete.

Translate
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 Beginner ,
Sep 13, 2021 Sep 13, 2021

I have not yet added a button for deleting a page, but will, and will definately add the script there. That part has already occurred to me. My issue is that some people will use an adobe version that will allow them to see the pages in the navigation pane and subsequently they will delete the page from here. This is where the problem lays - when the page is being deleted from the navigation pane. 

Translate
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 ,
Sep 13, 2021 Sep 13, 2021
LATEST

There's nothing you can do about that, as deleting a page (manually) does not trigger any event you can use to run a script. However, you can use the Page Open event of all the pages in your file. For example, you can save the number of pages in the file when it is first opened to a doc-level variable, and then add a script to the Page Open (and/or Page Close) event of each page comparing that number to the current number of pages. If they don't match, call calculateNow (and maybe update the value of this variable, to avoid unnecessary calculations later on).

Translate
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 ,
Sep 10, 2021 Sep 10, 2021

Where does you use the script?

Translate
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