NightWing Enterprises
Demo for FileMaker Pro™ 13+

Modular and Extensible Data Set Duplication

Duplicate Hierarchy v2.0

+ For FileMaker 13 and later +

For the benefit of clients and fellow developers, the following demonstration file is provided for free download.

There are three concepts that this demo serves to illustrate, one of which is somewhat self-evident and the other two a little less so.

At face-value, this example shows a method for automating the duplication of data in nested record sets across hierarchic 'tree' structures of unspecified depth and complexity. In itself this poses a set of challenges that, under scrutiny, are considerable. Duplicating a single record is child's play. Duplicating a parent record with an unknown set of child records is slightly more difficult. When there may be more than one 'branch' of child records and each child record may have one or more branches and each in turn must be mapped and duplicated exhaustively, you have an industrial-strength problem.

This demo solves the larger problem by interleaving two processes. One process exploits FileMaker's design functions to iteratively map all joins radiating out from the current user (layout) context - joins which might have records related to the current active record. The second process receives the map yielded by the first and follows it exhaustively, locating, re-creating and re-integrating each related record throughout the whole set (however 'deep') to return a complete and self-contained relational data set that is a copy of the original active record and its set of child (and grandchild, and great-grandchild, etc.) records. All the heavy lifting is done by the logic built into the pair of scripts provided in this example, making the process easy to implement. And even across hierarchies that are dozens of levels deep, the process is fast.

So, that's the more obvious subject matter of the demo - that's *what* it does. The second concept the demo serves to illustrate has to do more with *how* it does what it does. Significantly, the entire process of mapping and then recreating an unspecified number of parent and descendent records is completed from the current user contact -ie without changing layout and without leaving the active record (until the process is complete, when the script navigates to the duplicated parent record to display the result).

This technique is known as "processing in place" and offers numerous advantages over conventional FileMaker scripting, but is nevertheless a hidden gem for FileMaker development. Aside from potential improvements in speed of execution (depending on the nature of a given process), simplification of code and reduction of dependencies between code and interface elements, processing in place offers the benefits of fully transactional operation. Should an error be detected in the final stage(s) of a massive record duplication update, a single Revert Records/Requests command will drop the entire batch created set - including the duplicate record and all the related records to any depth - at a single stroke.

There is a third aspect of code design which is illustrated by this example file - the creation of FileMaker script code which has both modularity and portability. Although a global data input field (that supplies a preference setting regarding which fields' values are to be duplicated from each of the tables involved) and some standard graph elements are required (from the POV of each context where the script will be called) the scripts are otherwise context free. In particular, they don't map explicitly to any interface or schema elements - all reads and writes are calculated and indirect.

In addition to portability, the indirect nature of the code design also serves to allow a level of compactness of code despite the extent and complexity of the task in hand. The main script (leaving aside comment lines) is just 24 commands long, yet is capable of creating hundreds of records across dozens of different tables. It's also possible to run exactly the same script in completely different contexts (or, indeed, to copy it to different solutions) without making any changes at all to the code.

  ZIP archive
Duplicate Hierarchy v2.0 demo download (.zip archive)

Note 1:

The .zip archive download (above) provides a copy of the demo file suitable for all supported platforms.
Note 2: Before opening the demo file, please ensure you extract it from the .zip archive (eg to a local drive) - otherwise it will open in read-only mode and will not function as intended.
Duplicate Hierarchy v2.0 demo for FileMaker Pro 13 and later

This demo is provided free for private and educational purposes, and may be licensed for commercial and business applications. Should you require assistance implementing procedures such as those shown in our example files, please consider establishing an account with us for developer support.