Skip to main content
Inspiring
January 4, 2024
Answered

Can someone please help me with my custom calculation script that isn't working correctly?

  • January 4, 2024
  • 1 reply
  • 1269 views

Hi!

 

I'm using Adobe Acrobat Standard and I'm trying to write a custom calculation script but I'm missing something which is causing a wrong value to return.

 

This is the calculation script:

 

var v1 = 1 * this.getField("FIELD23").value;
var v2 = 1 * this.getField("FIELD32").value;
var v3 = 1 * this.getField("FIELD33").value;
var v4 = 1 * this.getField("FIELD42").value;
var v5 = 1 * this.getField("FIELD43").value;
var v6 = 1 * this.getField("FIELD34").value;

event.value = [(v3 * v1) * (v2)] + [(v5 * v1) * (v4)] + [(v6) * (v2 + v4)]

 

This is what the variables equal:

 

v1 = 60%
v2 = 8
v3 = $20
v4 = 8
v5 = $30
v6 = $5

 

It needs to calculate as follows:

 

20 (v3) x 60% (v1) = $12 * 8 (v2) = $96 +
30 (v5) * 60% (v1) = $18 * 8 (v4) = $144 +
5 (v6) * 8 (v2) + 8 (v4) = $80

 

The total should be $320 but I keep getting $9,614,480.

 

Can anyone help me please, please, please (before all the hair on my head is gone)? Where am I going wrong?

 

Thank you so much!!
Diane

This topic has been closed for replies.
Correct answer try67

Remove all the square brackets from the last line. Use only round ones.

1 reply

try67
try67Correct answer
Community Expert
January 4, 2024

Remove all the square brackets from the last line. Use only round ones.

Inspiring
January 4, 2024

YOU are AMAZING, try67, again my hero!! Thank you so much!! 🙂 I kept shuffling the bracketed numbers around but completely spaced on the brackets themselves. 

 

Thank you thank you thank you! And my scalp thanks you as well! 😉

 

Have a terrific evening!

Diane