I would do it the following way.
A separate masterpage and subform for each customer.
Each masterpage has a text object with two floating fields (pageIndex and pageSpan) for displaying the page counts.
The subforms (customer1, customer2 …) are placed on the corresponding masterpage via the pagination pallette.
I think your way is the right direction. My Form is build quite that way. I have two Masterpages. Just my data is not separated in two subforms as there are not just two, but like 300 customers. In the subform "STAR_FORM_DATERANGES_DATA" includes the main data (the other subforms are for hierachy reasons). On my first Masterpage (Startseite) there are two Content Areas "Header area" and "main area". The data subform "Header" is places in Content area "Header area", "star_month_per_gen" is placed on the the "main area" and Overflows into the second masterpage (Folgeseite), if there is not enough room on the first page. The subform "Tagesergebnisse" is growing according to each customers data. Every customer starts with on page of Masterpage "Startseite" and then Overflows into Masterpage "Folgeseite".
When i now use your code to get the pageSpan of "Star_FORM_DATERANGES", it is always the same, i think it is the pageSpan of the last customer. so if i have 3 customers with customer1 haveing 2 pages (1 Startseite, 1Folgeseite), customer2 having 5 pages (1 Startseite, 4 Folgeseite) and customer3 having 3 pages (1 Startseite, 2 Folgeseite) every page geht's the pageSpan 3.
Do you know why this happens? Do i do something wrong?
Thank you for your help, really appreciate it
P.S.: Here my hierachy:
Each Customer has 1 Masterpage "Startseite" and X Masterpages "Folgeseite". The whole data is in "STAR_FROM_DATERANGES_DATA". In the subform "Tagesergebnisse" there is a growing table for each customer.
I found another post from you on acrobatusers radzmar
There you used "xfa.resolveNodes("Masterpage[*]").length" to solve the problem and this totally works for me too.
Thank you very much for your time and effort
P.S.: For others having a similar problem, you can look at radzmar's solution here:
Got it solved by declaring a increment variable with default value as 1 in the first page and in the second page(flow-able) increase the count by 1. Get the Pagecount per instance by the child node length.