I hope you find this article interesting and, even better, useful to you in your efforts.
WIN A COPY OF MY NEXT EBOOK, FILEMAKER™ & YOU, VOLUME 2
After you've read the post, please take a moment to add a comment. (It helps me to know if I'm hitting the target with what I'm posting about). Anybody who comments will automatically be entered into a monthly drawing for a copy of my new book, due for release at the end of 2017. (1 out of 10 people will win a copy)
If you have bought either of my two previous books and haven't yet written a review on the iTunes store, please do so and then email me a copy of the review (so I know your email address) and you'll also be entered into a different monthly drawing where 1 out of 10 will also get a free copy).
Thanks and please don't hesitate to get in touch if I can help you.
Michael Rocharde
(303) 856-5778
It’s very easy to overlook the obvious and that is especially true when developing with FileMaker™. We know what we know and we often just go with that. In the process we build complexity where complexity isn’t necessary. As the Amish say “It’s a gift to be simple” and, personally, I always try to operate under the principal of KISS (Keep it simple, stupid). That doesn’t mean it takes any less time to develop something; sometimes it takes considerably longer but that extra time is, generally, spent thinking, about how to simplify, rather than writing code.
A common technique is to duplicate an existing record and then make the appropriate changes. However, the primary key has to then be changed otherwise you end up with incorrect links to related data. For years, I’ve written/used a script to Duplicate a record and, in the script, I then reset the primary key. This also meant using a Custom Menu with the standard Duplicate Record function replaced with the custom script.
Yesterday, I discovered a much better way to achieve the same objective and, to be perfectly honest, I feel a bit stupid for not ever thinking about it but, as I said, it’s very easy to overlook the obvious.
To create a primary key, we just use the Get(UUID) function. This create a string of some 26 characters and numbers with many trillions to one against that string being re-created so it is very safe to use as a primary key.
All you have to do in order for FileMaker™ to give a duplicated record a new primary key is uncheck Do not replace existing value of field (if any).
Yes, it really is that simple.
However, let me explain why it is important to have a new primary key assigned when duplicating a record. If you duplicate a record using the same primary key, all of the records that were related to the original record are now related to the new one which can cause enormous problems. Now, in truth, you’d probably notice that there were related records you hadn’t added to the new item but sometimes you won’t.
Hope this helps.
Michael Rocharde
Join our mailing list to receive the latest FileMaker tips, tricks and video how tos from Michael Rocharde
Join our mailing list to receive info on new videos as we post them
Leave a Reply
You must be logged in to post a comment.