Expand my Community achievements bar.

Don’t miss the AEM Skill Exchange in SF on Nov 14—hear from industry leaders, learn best practices, and enhance your AEM strategy with practical tips.
SOLVED

IF statement with two outcomes

Avatar

Level 4

I have an issue with an IF statement not producing the desired results; hoping that some of the experts here can readily solve the problem.

I have a series of textboxes (named PreBid1, PreBid2, etc.) that need to be populated with "Yes" and "No" answers AND make visible/invisible a button object. The answers are generated based on the selection of a radio button group.

if(form1.page1.subform1.status.rawValue == "Routine Oversight" || form1.page1.subform1.status.rawValue == "Enhanced Oversight" || form1.page1.subform1.status.rawValue == "Escalated Oversight"){

 

PreBid1.rawValue = "Yes";

Button1.presence = "visible";

}

else {

Button1.presence = "hidden";

PreBid1.rawValue = "";

}

The button's presence is working, but the PreBid1 text field is not populated with "Yes.". If I remove the Button1 statements, the Yes value populates.

I am sure this is simple, but I cannot figure it out.

1 Accepted Solution

Avatar

Correct answer by
Level 10

You need to swap the order of the lines

PreBid4.rawValue = "Yes";

Button1.presence = "visible";

to


Button1.presence = "visible";

PreBid4.rawValue = "Yes";

In the calculate event it is the last expression evaluated that is returned (so presence = "visible")

Regards

Bruce

View solution in original post

7 Replies

Avatar

Level 10

Hi,

Your code looks ok.  Happy to have a look at your form if you can share it.  Upload it to Google Docs, Dropbox, or whatever and post a link to it here.

Regards

Bruce

Avatar

Level 10

Hi,

Not sure I'm looking at the right thing, the code in PreBid4 looks like the above code but doesn't have the braces around the else statements ... looks like you have been trying lots of different code.

I've added those and it seems to be working https://sites.google.com/site/livecycledesignercookbooks/home/Untitled3.updated.pdf?attredirects=0&d...

Regards

Bruce

Avatar

Level 4

Bruce:

When I open your updated version, the value in PreBid4 is the word visible rather than the word yes.

Any thoughts?

Avatar

Correct answer by
Level 10

You need to swap the order of the lines

PreBid4.rawValue = "Yes";

Button1.presence = "visible";

to


Button1.presence = "visible";

PreBid4.rawValue = "Yes";

In the calculate event it is the last expression evaluated that is returned (so presence = "visible")

Regards

Bruce