Get the number of logical pages a subform spans

Avatar

Avatar
Validate 1
Level 1
Ashok1
Level 1

Likes

0 likes

Total Posts

12 posts

Correct reply

0 solutions
Top badges earned
Validate 1
View profile

Avatar
Validate 1
Level 1
Ashok1
Level 1

Likes

0 likes

Total Posts

12 posts

Correct reply

0 solutions
Top badges earned
Validate 1
View profile
Ashok1
Level 1

29-05-2020

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.

 

 

 

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar
Coach
MVP
radzmar
MVP

Likes

397 likes

Total Posts

2,687 posts

Correct reply

492 solutions
Top badges earned
Coach
Ignite 3
Ignite 1
Validate 1
Give Back 50
View profile

Avatar
Coach
MVP
radzmar
MVP

Likes

397 likes

Total Posts

2,687 posts

Correct reply

492 solutions
Top badges earned
Coach
Ignite 3
Ignite 1
Validate 1
Give Back 50
View profile
radzmar
MVP

30-05-2020

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

 

 

Answers (0)