field A cannot be more than 50% of field B | Community
Skip to main content
ReluctantProgrammer
Level 4
December 21, 2021
Solved

field A cannot be more than 50% of field B

  • December 21, 2021
  • 2 replies
  • 1119 views

I have a form which has two number fields that house formulas.  However, the second field can not be more than 50% of the first field, no matter what the calculation totals.  I.E.....

 

field 1 + field 2 = field A ($500)

field 3 + field 4 = field B ($400)

 

But field B cannot be any more that $250 (which is 50% of field A)

 

How can I do this?

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by Mayank_Tiwari

You may execute the following script on the calculate event of the field B:

 

var temp = fieldA.rawValue * 0.5;

if(fieldB.rawValue> temp)

fieldB.rawValue = temp;

2 replies

Mayank_Tiwari
Adobe Employee
Mayank_TiwariAdobe EmployeeAccepted solution
Adobe Employee
December 21, 2021

You may execute the following script on the calculate event of the field B:

 

var temp = fieldA.rawValue * 0.5;

if(fieldB.rawValue> temp)

fieldB.rawValue = temp;
ReluctantProgrammer
Level 4
December 21, 2021

That worked!

 

Thanks for your help!!

 

radzmar
Level 10
December 21, 2021

Hi,

 

use a calculation script like this.

 

var nSum = field1.rawValue + field3.rawValue;
if (!fieldA.isNull) {
    nSum = nSum <= fieldA.rawValue *.5 ? nSum : fieldA.rawValue;
}
this.rawValue = nSum;