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

Each record I create has a unique ID. When I create an new record that ID automatically increases by increments of 1.

 

When I create a record in error, and delete the errant record, I need to reset the next ID so it retains a linear progression.

 

I have created a simple script that allows me to reset the unique ID of the next record

 

Go to Record/Request/Page [Last]

Set Next Serial Value [Visit::Statement No.; Max (Visit::Statement No.) + 1]

 

The above script works, except for one thing:  I want the reset ID to read: "00000X" or "M0000X".

 

In each case the reset value increases to the next value, as required, however the FULL ID is ignored. For example "00005" when reset becomes "5". "M00005" when reset becomes "5".

 

How do I modify the above script to maintain the original ID configuration:  "00000X"  or M0000X"

 

Thanks

I want the reset ID to read: "00000X" or "M0000X".

 

The "or" part doesn't make sense here; you cannot be ambivalent when giving instructions to a computer. Assuming you want the same format as in the last record (which should be the format defined for the field), try:

 

Show All Records
Unsort Records
Go to Record/Request/Page [Last]
Set Next Serial Value [Visit::Statement No.; SerialIncrement ( Visit::Statement No. ; 1 )]

 

A better practice, IMHO, would be to set the serial number field to generate on commit, and make sure you do not commit newly created records unless and until you really want them (e.g. by using a "Post" button, followed by a "Are you sure?" confirm dialog).

 

 

---

P.S. Please update your profile to reflect your version and OS.

  • Author

Sorry about the confusion regarding "or" ... I was referring to using the script in 2 separate instances... so I wanted a script that was flexible enough to allow either instance. 

 

The script you provided works great.

 

I wrote this database in 1997, without any prior knowledge of FMP, and continually update its functions. I am not a professional, and understand only the surface of what I am working with. I am the only user... It works for me... but it is not as refined as I would like. I would very much like to add the "commit" function to ID entry.  It definitely sounds like a better practice.

 

Can you show me how you would write that script?

 

Thanks

 

Mark

The script itself is trivial:

Show Custom Dialog [ "Are you sure ..." ]
If [ Get ( LastMessageChoice ) = 1 ]
  Commit Records
End If

The non-trivial part is preventing accidental committing. For this, deselect the "Save record changes automatically" option in Layout Setup. However, doing (only) this will result in an annoying dialog being displayed whenever you click outside of any field. A relatively easy workaround is to place a large empty web viewer object in the background.

  • Author

Where can I find a general discussion of the "commit" function? What it does. How to implement it. Etc.

Thanks

On a slightly different note:

 


When I create a record in error, and delete the errant record, I need to reset the next ID so it retains a linear progression.

 

Why? How does it matter if the IDs are not in exact linear sequence?

 

Cheers

Webko

  • Author

Thanks for help with script... Works beautifully.

Regarding...

 

Why? How does it matter if the IDs are not in exact linear sequence?

I just like a clean database with clean reports. Is there another way to keep things orderly?

How does it matter if the IDs are not in exact linear sequence?

 

I have some clients that are obligated to number certain financial documents (Invoices, Receipts, etc.) strictly sequentially by their tax authorities.

 

 

I just like a clean database with clean reports. Is there another way to keep things orderly?

 

Why, yes. If you don't have to keep sequential IDs, you can just set-and-forget them. For reports, use a summary field to count your items. Or just the record number symbol.

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.