Skip to main content
Participant
November 28, 2020
Answered

Calculated fields not updating immediately

  • November 28, 2020
  • 1 reply
  • 1080 views

Hello,

I created an interactive field invoice in Acrobat. Fields are like:

qty1   unitprice1   discount1   total1

qty2   unitprice2   discount2   total2

qty3   unitprice3   discount3   total3

 

Fields qty[x] can be filled by the user, unitprice is fixed value, discount is calculated (example below), total is calculated (example below).

I noticed following thing which I would like to solve, because it can generate big errors:

- I write a number in qty1. The other fields in the row (unitprice1, unitprice1, discount1 and total1) are not filled in.

- I tap enter or tap on qty2 to enter the second quantity. The field unitprice1 and discount1 are filled in with the right value, but total1 is filled with zero.

- I fill in the value for qty2 where I am, and tap enter or go to the field qty3. The field unitprice2 and discount2 are filled in with the right value, but total2 is filled with zero. Total1 is updated to its correct value.

- I fill in the value for qty3 where I am, and tap enter or go to the field qty4. The field unitprice3 and discount3 are filled in with the right value, but total3 is filled with zero. Total2 is updated to its correct value.

 

What is making total[x] to be updating with basically the delay of one row?

 

Custom script for field total1:

if( this.getField( "qty1").value == 0 ) {event.value = "";}

else {event.value = this.getField("qty1").value * this.getField("unitprice1").value * (1- d1/100);}

 

Custom script for field discount1:

var q1 = this.getField( "qty1").value;

var d1 = "";

if( q1 < 2 ) {d1 = "";}

else if( q1 < 3 ) {d1 = 5;}

else if( q1 < 4 ) {d1 = 10;}

else if( q1 < 5 ) {d1 = 15;}

else if( q1 >= 5 ) {d1 = 20;}

event.value = d1;

 

Custom script for unitprice1:

if( this.getField( "qty1").value == 0 ) {event.value = "";} else {event.value = 50;}    (the logic here is to hide the unit price for articles which have zero quantity selected and to fill them only if they have a positive quantity)

 

Thanks a lot for your solution!

This topic has been closed for replies.
Correct answer Nesa Nurani

If you experience delay, check "Field calculation order" . 

1 reply

Nesa Nurani
Community Expert
Nesa NuraniCommunity ExpertCorrect answer
Community Expert
November 28, 2020

If you experience delay, check "Field calculation order" . 

Participant
November 28, 2020

Thanks a lot, did the job!