Replace Command For Missing FileMaker Primary Key Data

From Dwayne Wright PMP, PMI-ACP, CSM
Certified FileMaker Developer

WEB: www.dwaynewright.com
EMAIL: info@dwaynewright.com
TWITTER: dwaynewright
YOUTUBE: FileMakerThoughts

As you know, it is recommended that every FileMaker table have a field that uniquely defines that record with an auto enter, unique, sequential data string. This is often called a primary key field.

Ok, why would you want to have a field auto enter a serial number on each new record? Well, two reasons come to mind. One is for your use in searches or uniquely identify one record from another. Another reason is for the “under the hood” programing of FileMaker relationships. A huge majority of FileMaker relationships in any solution will involve a unique record id in at least one side of the relationship!

Now, let us chat a bit about the primary key field, otherwise known as the record id field, is a field that uniquely identifies each record in a file. It is almost always used as a parent key field. It is defined as auto enter data option when a new record is created and should be sequential. It can be saved in text or number format but I prefer text format myself. The primary key field should never be edited because it can break any existing child records. I do recommend that every table have an auto enter, sequential, non editable primary key field within it.

If your primary key field is empty on some records, it’s likely because you did not select that option when importing new records into that table. Not to fear, you can use the replace command to do this for you after the fact. Replace is a command under the Records menu that can be used to replace the contents of a field in all records of the current found set. You can exchange the fields contents with a data string, an incremental serial number string or a calculated result.

WARNING: Replace Field Contents script step is very flexible, very powerful and potentially very dangerous if misused. There is no undo for the replace command.

=
More info about the author and FileMaker in general, contact me at info@dwaynewright.com.

© 2008 - Dwayne Wright - dwaynewright.com

The material on this document is offered AS IS. There is NO REPRESENTATION OR WARRANTY, expressed or implied, nor does any other contributor to this document. WARRANTIES OF MERCHANT ABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE EXPRESSLY DISCLAIMED. Consequential and incidental damages are expressly excluded. FileMaker Pro is the registered trademark of FileMaker Inc.