Copy link to clipboard
Copied
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)
Copy link to clipboard
Copied
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 = "";
}
Copy link to clipboard
Copied
Hi Thom, thank you very much, but that didn't solve the problem.
Copy link to clipboard
Copied
Does the other field also have a calculated value?
Did you check the JS Console for error messages?
Copy link to clipboard
Copied
Copy link to clipboard
Copied
There is no "SUM monthly amount" field in your file.
Copy link to clipboard
Copied
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 🙂
Copy link to clipboard
Copied
Copy link to clipboard
Copied
SUMME monatlicher Betrag
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now