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.

Leading Zeros in a Serial Number via a Calculation?

Featured Replies

I have a Create New Record script that when it runs the first step it takes is it uses the 'Set Next Serial Value' script step using the Max Calculation:

Max (MATERIALREQUESTFORMS::MatlReq_Form# ) + 1

Then in a subsequent step it then uses the 'New Record/Request' script step to create the new record.

The problem I have is while I originally defined the field to use leading zeros in the serial number (by setting next value to 0006 for example) when the script runs it strips away the zeros and the next value I get is 7.

I there a way to add leading zeros via a calculation or is there some other way to do this?

Max() is a numerical operation - it returns a number. See also:

http://fmforums.com/forum/showtopic.php?tid/193363/

You could use SerialIncrement() on the result to restore the leading zeros. But a better solution would be to use an auto-entered serial ID. Otherwise you can get duplicate IDs when two users create a record at the same time.

  • Author

Thanks comment. I knew there was something that would work and while I swear I just read through my whole list of functions I just didn't see 'SerialIncrement()' (or I was just too impatient tonight to read through them carefully and attentively).

Regarding:

But a better solution would be to use an auto-entered serial ID. Otherwise you can get duplicate IDs when two users create a record at the same time.

That's not really a problem in this particular case since the chance of two simultaneous users creating a 'Materials Request Form' document at the same time are thousands to one and even if it did happen they would probably be for different Job Number and Job Name so that would be okay too.

And the KeyID for each 'Materials Request Form' is a Unique Key using a technique that accounts for simultaneous creation and I think I probably picked it up here years ago.

I know of NO method that can ensure unique IDs, other than Filemaker's built-in auto-entered serial number. That's not to say that such a method does not exist, only that I haven't seen one so far. Thousands to one are pretty good odds when you have thousands of records.

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.