Jump 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.

Featured Replies

hi all,

need desperate help in putting together a script to find missing numbers between the lowest and highest.

e.g.  1, 2.4,6,10

need a report to show the missing numbers 3,5,7,8,9

help is greatly appreciated

Thanks. 

Where are the existing numbers? 

  • Author

thanks for the quick reply,

The database is very simple; there are 5 fields the two key fields are "invoice No" and "Invoice Date", a users populates these two fields, i basically need a script that will find the missing invoice numbers between the lowest and highest numbers.

 

Thanks 

 

So they are in individual records? If so, you could do something like:

# FIND THE RELEVANT RECORDS
Show All Records
# SORT BY INVOICE NUMBER, ASCENDING
Sort Records [ Restore; No dialog ]
Set Variable [ $existingValues; Value:YourTable::sList ]
Set Variable [ $n; Value:GetValue ( $existingValues ; 1 ) ]
Set Variable [ $max; Value:GetAsNumber ( GetValue ( $existingValues ; ValueCount ( $existingValues ) ) ) ] 
Loop
  If [ IsEmpty ( FilterValues ( $n ; $existingValues ) ) ]
    Set Variable [ $missingValues; Value:List ( $missingValues ; $n ) ]
  End If
  Set Variable [ $n; Value:$n + 1 ] 
  Exit Loop If [ $n > $max ]
End Loop

At the end of the loop, the $missingValues variable should contain a return-separated list of the missing numbers. The sList field is a summary field defined as List of invoice No. If you prefer, you can eliminate it by doing a loop among the found set to collect the existing numbers.

Caveat:
You did not say how this is going to be used. It is good practice to use an auto-entered serial number to number invoices. It is also good practice to make sure there are no missing numbers by (a) assigning the number on record commit only and (b) preventing the deletion of committed records. It is certainly not good practice to try and reuse any numbers that may be missing.

 

  • Author

thanks for the script, i tried the above, but for some reason when i create a layout and place the sList field to show the list of missing invoices it shows the first number only repeated.

Thanks for the advice, in this instance all we need to do is collect a all invoices generated by the ERP and enter the number to keep track if the sales person turned the invoice into the accounts department, they were using excel but it got to be too many invoices.  

9 minutes ago, JMart said:

when i create a layout and place the sList field to show the list of missing invoices it shows the first number only repeated.

The sList field is not for showing missing invoices. It is meant to list the existing invoices. The script takes this list and generates the list of missing numbers into a variable.

See if the attached demo makes it clearer.

 

MissingNumbers.fmp12

Create an account or sign in to comment

Important Information

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

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.