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.

How can I have multiple actions in one event?

Avatar

Level 2

I  have been trying to search this, but I just can't figure it out. I want to have two separate if then expressions execute on a calculate event. I can only ever get the first one to execute. I need to have a "Rush" box checkmarked if the difference between 2 days is less than 10. Then I also need to have the box change to visible if the box is checkmarked. Here is my code.

if (IsoDate2Num(ClosingDate) - IsoDate2Num(DateReq)<="10") then form1.FloodDet.Rush.rawValue=1 endif;

if (Rush.rawValue==1) then Reason.presence = "visible" else Reason.presence = "invisible" Reason.rawValue = " " endif;

Help me get this working pretty please!

I realize I could probably just put them on separate fields but I figured there HAS TO be a way to do it this way.

4 Replies

Avatar

Level 10

Hi there,

you are mixing JavaScript with FormCalc, make sure to use only FormCalc

both if statement are wrong using formcalc

If the code above is still not working, try using Date2Num instead of IsoDate2Num, it basically does the same thing, I just never used IsoDate2Num

Always make sure to not put ";" at the end of statements, it is used as comments in FormCalc and end of line for JavaScript

Hope this help!

Avatar

Level 2

Yes, this definitely allowed me to put both of the If statements in the same event. Thank you! (I still have a lot to learn about the syntax of this stuff, I swore I had it right. I guess not )

One more question. Like I said, the "Rush" box will be automatically check marked if less than 10 days, then a "Reason for rush" box will open.

So for a while, I had each of these "IF" statements on separate fields. When I put the statement regarding visibility on the "reason for rush" field (calculate event) it shows the word "visible" in the text field. Any idea why this is happening? (see attached picture below.)

820514_pastedImage_0.png

Avatar

Level 10

Calculate event is set to purpose of setting the value's field for the user.

So the last line of code in the calculate event is the value inserted in the field...

So depends on what code you have written, this is what it returns

Avatar

Level 2

Excellent! Thank you for your help. With both of these tips, I was able to solve both of my issues.

thanks!