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

Trouble with calculations across many pages

Avatar

Level 1

I have a form with 12 pages. Calculations computed on page 8 need to be part of new calucations on page 2. I continiue to receive error messages stating total boxes from page 12 are unknown. When I move the caluation to be done on page 12 it does not reconize the total boxes needed for the calulation from page 2. PLEASE help. Page 8 as total of expenses that then need to be divided by the total requested on page two, for a percentage of request. Application is attached.

Thanks,

Sheila

1 Accepted Solution

Avatar

Correct answer by
Level 10

Hi,

There are a few total fields, so I am not sure which one you want.

However when you have selected the % field, click into the script editor. Then scroll down to page 8, so that you can see the total field you want to reference. Then click back into the editor and then with the mouse over the total field you want press and hold Control. This will turn the pointer into a 'V'. Then you now select the field, it will automatically insert the full reference of the field into your script.

I would recommend checking that the total expenses below the line is not 0 or null or you will get an error. I assign the resolved node into a variable and then refer to that variable in the if statement and the calculation.

var vTotalExp = xfa.resolveNode("FinancialExpenses.Subform14.#area.#area[1].ActualTotalExpenses")

if (vTotalExp <> 0 and vTotalExp <> null) then

     (TotalRequest/vTotalExp)*100

endif

Hope this helps,

Niall

View solution in original post

2 Replies

Avatar

Correct answer by
Level 10

Hi,

There are a few total fields, so I am not sure which one you want.

However when you have selected the % field, click into the script editor. Then scroll down to page 8, so that you can see the total field you want to reference. Then click back into the editor and then with the mouse over the total field you want press and hold Control. This will turn the pointer into a 'V'. Then you now select the field, it will automatically insert the full reference of the field into your script.

I would recommend checking that the total expenses below the line is not 0 or null or you will get an error. I assign the resolved node into a variable and then refer to that variable in the if statement and the calculation.

var vTotalExp = xfa.resolveNode("FinancialExpenses.Subform14.#area.#area[1].ActualTotalExpenses")

if (vTotalExp <> 0 and vTotalExp <> null) then

     (TotalRequest/vTotalExp)*100

endif

Hope this helps,

Niall

Avatar

Level 1

Thank you so much. That worked!