Expand my Community achievements bar.

Dive into Adobe Summit 2024! Explore curated list of AEM sessions & labs, register, connect with experts, ask questions, engage, and share insights. Don't miss the excitement.

If statements

Avatar

Former Community Member

Not finding the problem with this:

 

if  (NumericField2.rawValue*0.02 <100) {TotalAmount.rawValue=100;}

if  (NumericField2.rawValue*0.02>1000) {TotalAmount.rawValue=1000;}

if (NumericField2.rawValue*0.02 >100 and <1000 {TotalAmount.rawValue=NumericField2*0.02;}

6 Replies

Avatar

Level 2

What error are you getting?

One thing I noticed right away was that the and logic is performed with "&&".

Avatar

Former Community Member

I do not get an error in my script editor but when I enter the values in the form, it puts nothing into the TotalAmount field when my amount is between 100 and 1000

Avatar

Level 2

Oh sorry, you're using formcalc right?

For each if statement you need a then after your condition.

For exampple:

if  (NumericField2.rawValue*0.02 <100) then

     TotalAmount.rawValue=100

Avatar

Level 8

Make sure it's in JavaScript and change line 3 to:

if (NumericField2.rawValue*0.02 >100 && NumericField2.rawValue*0.02<1000)

Kyle