markdo Posted September 3, 2014 Posted September 3, 2014 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
comment Posted September 3, 2014 Posted September 3, 2014 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.
markdo Posted September 3, 2014 Author Posted September 3, 2014 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
comment Posted September 3, 2014 Posted September 3, 2014 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.
markdo Posted September 3, 2014 Author Posted September 3, 2014 Where can I find a general discussion of the "commit" function? What it does. How to implement it. Etc. Thanks
comment Posted September 3, 2014 Posted September 3, 2014 There's an excellent article by Ilyse Kazar (sp?) here: http://www.filemaker.com/downloads/pdf/techbrief_fm8_migrtn_found.pdf
webko Posted September 3, 2014 Posted September 3, 2014 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
markdo Posted September 4, 2014 Author Posted September 4, 2014 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?
comment Posted September 4, 2014 Posted September 4, 2014 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.
Recommended Posts
This topic is 4124 days old. Please don't post here. Open a new topic instead.
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now