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

Value is not updated

Community Beginner ,
Feb 17, 2024 Feb 17, 2024

Hello, I am creating a form and have a problem with the calculation of a value. The formula does not update.

 

The value to be calculated is in the field:
"SUM monthly amount"

 

The formula is:
var sum = +getField("SUM monthly amount").value *12/52;
if (sum !== 0) {
event.value = sum;
} else {
event.value = "";
}

 

The first time I fill in the field, the calculation is performed, but as soon as I change the value in the field "SUM monthly amount", the value to be calculated is not updated.

All other calculations work and are also updated.

Translated with www.DeepL.com/Translator (free version)

TOPICS
PDF forms
2.2K
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 ,
Feb 17, 2024 Feb 17, 2024

Is this code placed in the custom calculation script for a field other than "SUM monthly amount"?

Try this small fixup:

 

var sum = this.getField("SUM monthly amount").value *12/52;
if (sum != 0) {
   event.value = sum;
} else {
   event.value = "";
}

 

 

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

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 ,
Feb 17, 2024 Feb 17, 2024

Hi Thom, thank you very much, but that didn't solve the problem.

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 ,
Feb 17, 2024 Feb 17, 2024

Does the other field also have a calculated value?

Did you check the JS Console for error messages?

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 ,
Feb 17, 2024 Feb 17, 2024

Yes, it has. Maybe it makes sense if I upload the form here.

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 ,
Feb 17, 2024 Feb 17, 2024

There is no "SUM monthly amount" field in your file.

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 ,
Feb 18, 2024 Feb 18, 2024

To be honest, I don't know anything about javascript, or I'm just trying to learn it. I looked it all up on google and a bit of logic 🙂

 

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 ,
Feb 18, 2024 Feb 18, 2024

Hello Nesa, thank you for taking a look at this. Sorry, my mistake, the form is in German and the field is called "SUM monthly amount". It is in tab 7.

Here is the file again, I have just seen that tab 6 "Reserves..." has no formula.

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 ,
Feb 18, 2024 Feb 18, 2024

SUMME monatlicher Betrag

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 ,
Feb 18, 2024 Feb 18, 2024

These are the errors reported in console:
TypeError: getField(...) is null
1:Field:Calculate
TypeError: getField(...) is null
1:Field:Calculate
TypeError: this.getField(...) is null
1:Field:Calculate
TypeError: getField(...) is null
1:Field:Calculate
TypeError: getField(...) is null
1:Field:Calculate
TypeError: this.getField(...) is null
1:Field:Calculate

 

That means that you use wrong field names in your scripts, check your scripts and make sure field names are correct. Also, there are some unnecessary scripts, where you can, you should use built in calculations instead of custom calculation scripts.

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 ,
Feb 18, 2024 Feb 18, 2024
LATEST

Oops, thanks. You can see that I'm a total layman. I'll check it and try to correct it. But I think I'll get back to you here.

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