Skip to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Page number confusion

Featured Replies

I print 2 certificates which form a pair, previewing each in a standard form layout first. Each has its own 'preview' script. All certificates/records are deleted via 'print' and 'cancel' scripts.

Certificates from related record nos 9001, 9003 & 9005 will display pages numbered 1 of 6, 3 of 6 and 5 of 6, whilst related record nos 9002, 9004 & 9006 will display with certificates with pages numbered 2 of 6, 4 of 6 and 6 of 6 (totals are likely to be a lot bigger).

When I run the first script, I get the correct result.

When I run the second script without running the first script, I get the correct result.

When I run the second script after running the first script (ie: with both windows displayed), it creates a certificate for all the records ie: 2 of 12, 4 of 12 > 12 of 12.

I expected that to be fairly easy to debug but…

When I run the second script using the debugger (after running the first script), I get the correct result.

What really throws me is that, if I 'cancel' the incorrect preview (which deletes the certificates/records and closes the window), and run the same script again, I get the correct result.

What am I looking for? …how could one script get 2 results?

  • Author

I've discovered what is happening but I don't understand why!

Both scripts find all records relating to a Job No (resulting in 6 records as described before). They then, by looping through, omit half each - the first script omitting even page numbers, the second omitting odd. Then it opens a new window switches to a related table/layout and creates the certificate, looping through the found set in the first window to create the three certificates.

Somehow, the second script has all three even page numbered certificates as soon as the new window/table/layout is chosen, without the 'New Record script step or any looping to create multiple certificates (the latter was simply duplicating a set of certificates).

I'm at a loss as to how this is happening.

FMP does not natively display "Page XX of YY" so a developer has created the functionality. Most probably the last page number is stored in a global field and it is set as part of the scripted preview process:

Enter preview mode

Go to last page

Set field: gLastPage = get( pageNumber )

Go to first page

In this case the problem is that there is only 1 global field, and it's being updated for the second preview while the first preview is still open.

  • Author

You're right, that is causing the '12' when it should be '6'. But I still have the second script finding the certificates and page numbering them correctly before it runs through the loop in the script that is there to find that information. I suppose, as long as it gets the correct result, why should I worry!

Create an account or sign in to comment

Important Information

By using this site, you agree to our Terms of Use.

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.