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.

number generating scripts that are record independent

Featured Replies

I'm writing a script to generate sequential numbers when attached to a button. It works fine in an individual record, but when I open a new record it resets itself to 1. Is there a way to keep the current number from record to record while continually adding on to said number?

Sequential numbers (serial numbers) are easily set under Define: Fields/Options, and when used, are assigned automatically on the creation of a new record. This would avoid the need for a script.

Hope this is useful.

Peace

Keith M. Davie

  • Author

I had used that method at first, but then ran into the obstacle of needing to generate multiple numbers per record, so the serial number option wasn't satisfying that need. Sometimes I need 1 or more numbers for an individual record, then on the next record I need the next consecutive number from the previous record.

quote:

Originally posted by smoothdra:

I had used that method at first, but then ran into the obstacle of needing to generate multiple numbers per record, so the serial number option wasn't satisfying that need. Sometimes I need 1 or more numbers for an individual record, then on the next record I need the next consecutive number from the previous record.

Assuming you have 1 field which stores this number and only 1 number in this field, heres what you can do:

Setup a self-relationship by a constant (i.e. a calculation field = 1) and then sort the relationship in descending order by your number field. Now the highest number is the first record in the relationship and you can use "Number = RelationshipName::Number + 1" to get the next highest number.

If the numbers are stored in more than one field or multiple numbers are stored in the field. Use the "Max(field1, field2, etc)" in a calculated field to get the highest number in that record. Then base the relationship and other calculations on this field.

------------------

=-=-=-=-=-=-=-=-=-=-=-=-=

Kurt Knippel

Senior Filemaker Developer

http://www.inthescene.com

mailto:[email protected]

=-=-=-=-=-=-=-=-=-=-=-=-=

You might want to try using a global field to store the last number used.

Then your script could follow these steps:

1) Insert Calculated result of the global field + 1 (called Paste result in older versions)

2) Copy the new result and paste back to global field.

Good luck.

Go to the following website. http://www.databasepros.com/index.html

Go to the Tips & Tricks Section and search for the files on Serials. There are a couple of excellent downloads there.

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.