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

Calculations with instanceManager Count

Avatar

Level 3

I have a total sum field that takes values from two different subforms. One subform has an initial count of 0.

If users want, they can "add" that subform into view.

So, I imagine I need two if conditions for my calculations. One with only 1 subform and one with 2 subforms.

under calculate event

formCalc

I tried this:

if (RepeatWrap.instanceManager.count == 0 ) then

$.rawValue =  Sum(Table1.Row[*].Cell8);

else

$.rawValue =  Sum(Table1.Row[*].Cell8)+Sum(RepeatWrap[*].Table1.Row[*].Cell8);
endif

RepeatWrap is the second subform.

If course this is not working..

Is it my syntax or my logic? Most likely both... T_T

Many thanks in advance

1 Accepted Solution

Avatar

Correct answer by
Level 3

I've solved my own syntax errors.

the solution for a Logic IF statement in formCalc under Calculate event:

if (RepeatWrap.instanceManager.count eq "0")

then

$.rawValue=sum(Table1.Row[*].Cell8)

else

$.rawValue=sum(Table1.Row[*].Cell8+(RepeatWrap[*].Table1.Row[*].Cell8)

end if

Hope this serves as a good reference.

View solution in original post

1 Reply

Avatar

Correct answer by
Level 3

I've solved my own syntax errors.

the solution for a Logic IF statement in formCalc under Calculate event:

if (RepeatWrap.instanceManager.count eq "0")

then

$.rawValue=sum(Table1.Row[*].Cell8)

else

$.rawValue=sum(Table1.Row[*].Cell8+(RepeatWrap[*].Table1.Row[*].Cell8)

end if

Hope this serves as a good reference.