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.

Script to reset auto serial # to 1

Featured Replies

Hi all,

I have an FM9 database (OS 10.5) that I'd like to include a script step which will reset the serial number in the field definition to 1 (and increment by 1). The file is made of up several related tables and is used for quarterly report data. The main db is a customer info db and then the main related file is a transaction db. Each quarter would get a new customer info record and I'd like transactions to restart the auto serial number at 1 for each quarter. Right now, it's up to 250 or so and instead of manually going into the field definition each quarter to reset, I'd like a script that creates the new customer record and resets the serial # for the transaction records as part of the script. I'm not sure if the "Set Next Serial Value" is the correct step and if so, I'm not sure how to properly se it up.

Any help is appreciated. Thank you!

Yes Set Next Serial Value could be used to reset the serial number of an auto-serial number field

However...

Please keep in mind that you should never do with with a field that is used a as a primary key. The primary key should always be a unique auto-generated serial that is not reset.

  • Author

Thanks. At least I'm heading in the right direction. The serial is not the primary key for the db (I do know better than that B) ). But now that I think about it more, I don't know why I don't just use "@@" for the record numbers and take the field out completely. Duh!

But just as a learning opportunity, I set the calculation for the step to be transdb::record number = 1 and it set the serial number to zero. Why was that? If 1 doesn't set it to 1, then what does?

Thanks again! :thankyou:

Not sure... It look slike this correct?

Set Next Serial Value [ transdb::record number; 1 ]

You set it to a calc that evaluates as true (1) or false (0).

Just set it to "1" (no quotes), not "x=1."

  • Author

Thanks Fitch! I get it now. And thanks too, John, mine didn't look like what you said. I thought you needed more in the calculation part of the step than just a number. But the change helped, and now it does what I thought it should do.

For this database though, I'm just going to use the Record Number Symbol instead. That's all this one really needed and I should have thought of that sooner. But, sometimes, I just like doing things the hard way.

:Whistle:

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.