Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

SOLVED

field A cannot be more than 50% of field B

ReluctantProgrammer
Level 2
Level 2

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?

1 Accepted Solution
Mayank_Tiwari
Correct answer by
Employee
Employee

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;

View solution in original post

3 Replies
Mayank_Tiwari
Correct answer by
Employee
Employee

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;
radzmar
Level 10
Level 10

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;