Expand my Community achievements bar.

Referencing subform instances

Avatar

Level 3

I have a tricky issue now that I am hoping someone can help with. I have an 8 page XFA form where the first 4 pages cannot be made expandable because the recipient company has to scan them when sent in by customers - so layout has to stay fixed. On page 2 there are three tables with fixed number of rows where the user can declare their shares in different currencies. If they have more shares than the rows allow, or more currencies, they can go to page 6 where they can add other currencies or more of the same currency from page 2. Each currency subform on page 6 is dynamic, and can have as many rows as needed.

At the bottom of page 2 is where the totals of each currency for the whole form have to be declared individually - so £ from page 2 and page 6 (continuation), $ from page 2 and 6, and so on - reported as "£xx + $xx + Rxx".

I have the form dropping each page 6 subform totals of each currency into separate boxes (eventually to be hidden) so that they can contribute to page 2 totals.

The problem I have is that only the first instance from the page 6 currency contributing to the section 6 total - whichever currency is declared first. The others do not contribute.

The script (FormCalc)calling that is:

 

var do1 = Sum(topmostSubform.Page2.p2content.total_aggregate_nominal_dollar.rawValue) //page 2 value

var do2 = Sum(topmostSubform.Page2.p2content.total_aggregate_nominal_dollar2.rawValue) //alternative page 2 value

var do3 = topmostSubform.Page6.currency.Row2[*].calcs.total_aggregate_cont_dollar.rawValue //page 6 value

 

if (do1 >= 1)

then 

$ = do1 + do3

elseif (do2 >= 1)

then 

$ = do2 + do3

endif

What do I have wrong? Would I be better off in Javascript? 

8 Replies

Avatar

Level 10

Hi, I would suggest you change the operators for FormCalc operators such as '>=' should be 'ge' for greater or equal too

other than that make sure that $ is referenced to the right object you are suppose to work in

Avatar

Level 3

I have changed the operators to no effect. I think the problem has to do with the third variable

var do3 = topmostSubform.Page6.currency.Row2[*].calcs.total_aggregate_cont_dollar.rawValue //page 6 value


this only provides the value of the first instance of  the subform "currency" = this subform contains the value total_aggregate_cont_dollar - I want it to find that value from whichever instance of currency it occurs

Avatar

Level 10

You must add the function Sum() to have each value together

as long as this is formcalc and not javascript

Avatar

Level 3

Maybe I was not clear - the totals on page 2 are for each currency on their own - I already have another area where it collects the total number of shares into a single total, and that is already a Sum, and works fine collecting up figures from around the form.

This issue here is that one field collects all the values for one currency, another field for another currency. The script I have shown is to collect up all contributing figures for dollars. I have other scripts for the other currencies.

I suspect I have the logic all wrong for this.

Avatar

Level 10

Okay, well what are you trying to do with do3???

Usually using the [*] is meant to get all instances of a subform/field... to be able to get each values.

I'm still not exactly sure what you are trying to do since you already have a sum() working...

Avatar

Level 3

For each currency, the user can declare as many shares as they like for that currency - that is where the sum is. The do3 var is getting that sum - and transferring it to another area. If the user declares another currency (so now they have 2 currencies, again they can add as many shares in that currency. Again the do3 is supposed to grab that new value for the new currency, and transfer it to that other area, but to a different variable. Do you want me to send you the PDF?

Avatar

Level 10

Hi,

Yes I can take a look at it, but could you give an example of what you are trying to do here, I am not sure if I get the shares you are trying to implement...

Avatar

Level 3

I have figured this out myself - it turned out that the recalculate was not working, so I had to use .execCalculate rather, plus a few other workarounds