AnsweredAssumed Answered

How To Duplicate a Record with Related Records

Question asked by russbrad on Aug 8, 2012
Latest reply on Aug 8, 2012 by russbrad

I'm aware this is a common request, and I've seen some threads detailing how to do it in broad strokes, but I'm still lost as to the specifics.


I have tables of Quotes, Components and Line Items, in descending hierarchical order. So a Quote has Components, and a Component has Line Items. The Quote building screen is actually a Component layout that views other Components through a self-join portal.


What I want to be able to do is duplicate a Component on the same Quote with all of its Line Items.


Now, I understand the broad strokes theory:


1 Copy original Component id to variable

2 Duplicate Component

3 Create new id for Duplicated Component and store as variable


4 Go to Original Component

5 Get related Line Items

6 Duplicate Line Item and copy the Duplicated Component id into the appropriate field, repeat until all Line Items are duplicated


7 Go to Duplicated Component to view it

8 Profit


The problem is, I don't understand how to get back to the Original Component, or how to loop through the associated Line Items for the Original Component and duplicate them. Something about the logic of it just isn't clicking for me. Is there a standard way to do this that will help me?


As a side note, I come from a programming background, and there people talk about the "pointer epiphany", when you finally get what pointers are and what they do, and then a lot of things suddenly make sense because you understand what's happening under the hood. I think there might be a similar epiphany that I have to have when it comes to databases, but I don't know what it is. I just don't seem to be able to synthesise solutions to problems in Filemaker the way I can when writing code, so if anyone can help me understand where to look for this insight, I would appreciate it.