Need help in establishing a minimum value on Adobe field

New Here ,
Feb 08, 2021 Feb 08, 2021

Copy link to clipboard

Copied

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>

TOPICS
Create PDFs, How to, JavaScript, PDF forms

Views

64

Likes

translate

Translate

Translate

Report

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
Adobe Community Professional ,
Feb 09, 2021 Feb 09, 2021

Copy link to clipboard

Copied

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;
}

 

Likes

translate

Translate

Translate

Report

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
New Here ,
Feb 12, 2021 Feb 12, 2021

Copy link to clipboard

Copied

Thanks for the help. 

Likes

translate

Translate

Translate

Report

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