Expand my Community achievements bar.

Guidelines for the Responsible Use of Generative AI in the Experience Cloud Community.
SOLVED

Get the number of logical pages a subform spans

Avatar

Level 2

I am using the below script to get the  number of pages where subform spans

xfa.layout.pageSpan(subform);

but it is giving number of pages where first instance of subform spans.

I have to get the number of pages where current instance of subform spans.

 

thanks in advance.

 

 

 

1 Accepted Solution

Avatar

Correct answer by
Level 10

I think the problem is you're referencing th first instance of the subform and so getting always the number of pages it spans.

Given your subform is named "customer" than the code xfa.layout.pageSpan(customer) really means xfa.layout.pageSpan(customer[0]) which is the first instance. For repeated objects you'll need to address the desired instance. This can be done either direct or relative.

 

For the direct way you'll have to know the SOM expression of the addressed object in question. This means to use SOM expressions with accessors []. In difference to FormCalc you can't use those SOM expressions with accessors as argument in JavaScript because of the square brackets. That's why it's wrapped in a resolveNode() method as a string.

// Get the page span of the third instance of the object 'customer' under form1.page. 
xfa.layout.pageSpan(form1.page.resolveNode("customer[2]")); // JavaScript

xfa.layout.pageSpan(form1.page.customer[2]); // FormCalc

 

If the script is executed for an object which resides within the object to be addressed, you can use use a relative expression starting from the current object. It's much easier, since you don't have to deal with complex SOM expressions.

xfa.layout.pageSpan(this.parent); // Get the page span of a subform that surrounds this fields

 

 

View solution in original post

1 Reply

Avatar

Correct answer by
Level 10

I think the problem is you're referencing th first instance of the subform and so getting always the number of pages it spans.

Given your subform is named "customer" than the code xfa.layout.pageSpan(customer) really means xfa.layout.pageSpan(customer[0]) which is the first instance. For repeated objects you'll need to address the desired instance. This can be done either direct or relative.

 

For the direct way you'll have to know the SOM expression of the addressed object in question. This means to use SOM expressions with accessors []. In difference to FormCalc you can't use those SOM expressions with accessors as argument in JavaScript because of the square brackets. That's why it's wrapped in a resolveNode() method as a string.

// Get the page span of the third instance of the object 'customer' under form1.page. 
xfa.layout.pageSpan(form1.page.resolveNode("customer[2]")); // JavaScript

xfa.layout.pageSpan(form1.page.customer[2]); // FormCalc

 

If the script is executed for an object which resides within the object to be addressed, you can use use a relative expression starting from the current object. It's much easier, since you don't have to deal with complex SOM expressions.

xfa.layout.pageSpan(this.parent); // Get the page span of a subform that surrounds this fields