Skip to main content
Participant
February 8, 2021
Question

Need help in establishing a minimum value on Adobe field

  • February 8, 2021
  • 2 replies
  • 622 views

I am computing a value of a system we are auditing. The field is CashValue. It is calulating correctly except that I want to set a minimum value of 1000. What do I need to change? Here is the code that Adobe generated. 

 

//<AcroForm>
//<ACRO_source>CashValue:Calculate</ACRO_source>
//<ACRO_script>
/*********** belongs to: AcroForm:CashValue:Calculate ***********/
/** BVCALC (1-Discount)*Average EVCALC **/event.value=(1-AFMakeNumber(getField("Discount").value))*AFMakeNumber(getField("Average").value)
//</ACRO_script>
//</AcroForm>

This topic has been closed for replies.

2 replies

Participant
February 12, 2021

Thanks for the help. 

Karl Heinz  Kremer
Community Expert
Community Expert
February 9, 2021

Let me see if I have this correct: You want to calculate the field by multiplying Discount and Average, and if the result is less than 1000, use 1000 as the calculated value. Is that correct? If so, you need to switch to a JavaScript calculation script. The simple field calculation will not be able to do that. Try the following script:

 

var val = Number(this.getField("Discount").value) * Number(this.getField("Average").value);

if (val < 1000) {
    event.value = 1000;
}
else {
    event.value = val;
}