Duplicating Related Records - Server Side

The age old question commonly arises on FileMaker forums around the world. "How can I duplicate the whole record?" In other words, how can I duplicate the parent record and all related children records which make it seem like it's one whole entity.

Well, at least, that's how a newer user/developer sees it. They may visually see the one record with all of its related records presented within the portal, but making the distinction that you're actually looking at 1 record plus N related records isn't super obvious from a UI standpoint.

However, as a FileMaker developer, you need to know how to duplicate the whole collection of records so the user can conveniently click that one single button which reads "Duplicate". There are many methods you can use to accomplish this task, but there are a few tricks to making to work successfully and reliably depending on your specific requirements.

In this video I present one of the most efficient methods for duplicating whole related record sets. No matter how many sets of related records you have, you can always take advantage of the inside knowledge on how to accomplish this type of task in FileMaker Pro.

AttachmentSize
DuplicatingRelatedRecords.zip1.66 MB

Comments

Hey Matt,
We tried to implement your brilliant solution and are mighty proud, that we found a "real" error in your code.
You use in your Custom Function IsRunningOnServer " Leftwords (Get(Applicationversion):1)="Server".. but should use Get(HostApplicationversion). Applicationversion returns for example 17.1 and NEVER returns "Server". So your script in this form NEVER will run on server. Am I right? Not totally sure!

Matt..
Sorry.. You where right. When the script calls itself via Run on Server THEN Get(application version) returns "Server 17.0.04 or whatever and you jump to the main script....One never sees this and cannot see it, since there is no tools to Debug Run on Server..
I was totally wrong.. but since it is so difficult to understand I think you should have pondered more time on this nice little detail in your video.
thanks anyway for the great content...

( Note Matt said this in the video )

In another setting I needed to move data from one tabel / file to another.
You are right, it won't work with a FM -> FM script step.

You can, however, on server export the data in excel format and import that file again. It is a little tedious if fields get added/deleted, but it works.

This is also really fast.

Kind regards,

Joost Miltenburg, The Netherlands

Hi Matt, nice technique, as always. I have added some more fields to duplicate and added them in the relationship graph to the duplication relationship. I noticed if any of the match fields are empty in the original line item record then this line item will not be duplicated. This could be useful or it could cause problems. In my case I have added a "trap" to enter some value into empty fields ( 0 / zero works fine.) Just thought I would pass this on in case anyone else runs in to this issue.