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.
SOLVED

If Then statement question, multiple conditions

Avatar

Former Community Member

I am trying to create a form where I have 2 boxes that a user can put a number in, and a third box that inserts a number based on what is put into the first 2 boxes.The default value for all 3 boxes is 0. For example, if the 1st box contains any number greater than 0, the number 7 is put into the 3rd box. However, regardless of what is in the 1st box, if the 2nd box contains a number greater than 0, the number 24 is put into the 3rd box. I am using FormCalc. Any help  is appreciated!!!!!

1 Accepted Solution

Avatar

Correct answer by
Former Community Member

The issue is that you have a capital I in the If satatement. Make it a lowercase i

Paul

View solution in original post

5 Replies

Avatar

Former Community Member

Assuming the boxes are called Box1, Box2 and Box3. I woudl also use Javascript (it is much more widely used) although you can use FormCalc if you insist. The code would look something like this:

if (Box1.rawValue > 0){

     Box3.rawValue = 7;

}

if (Box2.rawValue > 0){

     Box3.rawValue = 24;

}

paul

Avatar

Former Community Member

Paul,

I inserted the code as you said, but am not getting anything placed into Box3. I'm not sure what I'm doing wrong. I am attaching the file so you can see. If you look at the bottom of the 2nd page, it is the boxes for "Reprimand" (Box1) and "Suspension" (Box2) under "Disciplinary Actions" and "Disciplinary Score" (Box3). If any value greater than 0 is put into "Reprimand", then "Disciplinary Score" should show "7". Regardless of what is put into "Reprimand", if any value greater than 0 is put into "Suspension", then "Disciplinary Score" should show "17" (not 24 as I originally posted).

Thanks for your help!!!

Gene-O

Avatar

Correct answer by
Former Community Member

The issue is that you have a capital I in the If satatement. Make it a lowercase i

Paul

Avatar

Former Community Member

You are my hero!!!

Thanks so much, however, I have one more issue: I also would like to add a statement that basically says that if Box1 and Box2 are both = 0, then Box 3=0. But that statement cannot interfere with the other statements. It is just a way to return everything to 0. The reason is once I enter a number into Box1 or Box2, then I cannot zero out Box3 again.

Thanks again!

Avatar

Former Community Member

Paul,

I got it figured out. Thanks again for your help!!!!

Merry Christmas

Gene-O

The following has evaluated to null or missing: ==> liqladmin("SELECT id, value FROM metrics WHERE id = 'net_accepted_solutions' and user.id = '${acceptedAnswer.author.id}'").data.items [in template "analytics-container" at line 83, column 41] ---- Tip: It's the step after the last dot that caused this error, not those before it. ---- Tip: If the failing expression is known to be legally refer to something that's sometimes null or missing, either specify a default value like myOptionalVar!myDefault, or use <#if myOptionalVar??>when-present<#else>when-missing. (These only cover the last step of the expression; to cover the whole expression, use parenthesis: (myOptionalVar.foo)!myDefault, (myOptionalVar.foo)?? ---- ---- FTL stack trace ("~" means nesting-related): - Failed at: #assign answerAuthorNetSolutions = li... [in template "analytics-container" at line 83, column 5] ----