Post pagination script - pageCount returning wrong count

Hi,

Just wondering if someone can shed a light on this for me please:

I have a template with 2 sections:

  • Main section - with dynamic tables ; overflow pages – omitting empty page
  • Last section – housing the last table content , simplex – omitting empty page

See screenshot below. Basically I have post script to target just the last section. I have a loop through all sections and grabs the pageCount of the main section
But this pageCount is false. When I have 2 pages in the main section its returning 4, when I have 3 the page count of main is zero.

What is going on here? Isnt post pagination script triggers after all sections has been paginated. But Im looping through each one and its giving me wrong page count value :frowning:

I feel like, Im misunderstanding post pagination script here.

Im on version Connect v2023.1.0.15090

To add , I run the debugger. Its completely wrong.

UPDATE

I realized I have a clone happening in the control script and thats probably why its giving a different page count. Apologize for jumping the gun there.

Cheers