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.

Show/ Hide subforms based on drop-down list

Avatar

Level 2

I have received to much help from everyone and I really appreciate it. Now I have something that has got me scratching my head for a week now and I don't understand.

 

Back to my form, I have some textboxes with learner's info and a drop-down list of how old they are. If they are young learners (16-18 years), there are only a certain number of apprentices they can take on.

 

So I have made it so that if "Future Talent" is chosen, a Future Talent course subform appear with 3 fields, a drop-down list to pick the course, 2 datefields: StartDate & EndDate. When "In Situ" is chosen a different subform appear with the same fields (different names) and 2 extra fields. 

 

These are the courses for older learners:

thaong_0-1585924059315.png

 

These are the courses for young learners

 

thaong_1-1585924087223.png

 

Now when I choose a Program on the In Situ subform and pick a startdate, the enddate works perfectly. However, when I choose a Program in the Future Talent and a startdate, nothing happens. Fields in FT subform are similar to the other one, I just add ft at the end.

 

This is the code for In Situ:

 

form1.MainPage.FlowSubFormInSitu.StartDateSub.StartDate::exit - (FormCalc, client)

if(HasValue(StartDate)) then
var fStart = Date2Num(StartDate.formattedValue, "DD/MM/YYYY")
var fMonth = Num2Date(fStart, "MM")
var fDate = Num2Date(fStart, "DD")
var fYear = Num2Date(fStart, "YYYY")
var nSelection = Programs

if (nSelection == "1" or nSelection == "3" or nSelection == "5" or nSelection == "8" ) then
fMonth = fMonth + 18
fYear = fYear + Floor(fMonth / 12)
fMonth = Mod(fMonth, 12)
if (fMonth == 0)then
fMonth = fMonth + 18
endif
fMonth = Format("99", fMonth)
var sNewDate = Concat(fYear, "-", fMonth, "-", fDate)
newDate.formattedValue = Num2Date(IsoDate2Num(sNewDate),"DD/MM/YYYY")

elseif(nSelection == "2" or nSelection == "4" or nSelection == "6") then
fMonth = fMonth + 15
fYear = fYear + Floor(fMonth / 12)
fMonth = Mod(fMonth, 12)
if (fMonth == 0)then
fMonth = fMonth + 15
endif// format month to 2 numbers
fMonth = Format("99", fMonth)// create Iso Date string
var sNewDate = Concat(fYear, "-", fMonth, "-", fDate)
newDate.formattedValue = Num2Date(IsoDate2Num(sNewDate),"DD/MM/YYYY")

else
fMonth = fMonth + 21
fYear = fYear + Floor(fMonth / 12)
fMonth = Mod(fMonth, 12)
if (fMonth == 0)then
fMonth = fMonth + 21
endif// format month to 2 numbers
fMonth = Format("99", fMonth)
var sNewDate = Concat(fYear, "-", fMonth, "-", fDate)// display result
newDate.formattedValue = Num2Date(IsoDate2Num(sNewDate),"DD/MM/YYYY")
endif
else
null
endif

 

The lengths of programs are the same so why does one work and the other doesn't?

0 Replies