8 Replies Latest reply on Apr 26, 2015 2:29 PM by jgalt

    Duplicating a table with relationships

    kathryn300

      I have a table and when I duplicate a record on it I want to duplicate all the corresponding entries on my many-to-many relationship table. Is this possible?

        • 1. Re: Duplicating a table with relationships
          DavidZakary

          It can take a lot of work to do this. FileMaker doesn't automatically duplicate any of the child records for a parent record.

           

          Here's the usual process...

          • Start with the parent record, grab the primary key value and store it somewhere (global or variable)
          • Duplicate the parent record, store it's primary key somewhere
          • For each child table...
            • Navigate to a layout based on that table
            • Find all records for the ORIGINAL foreign key (the parent being duplicated)
            • Start duplicating each child record, setting the foreign key to the key value of the duplicated parent. This is generally a looping process
          • Repeat for each child table to you need to duplicate records in
          • 2. Re: Duplicating a table with relationships
            RayCologon

            kathryn300 wrote:

             

            I have a table and when I duplicate a record on it I want to duplicate all the corresponding entries on my many-to-many relationship table. Is this possible?

             

            Hi Kathryn,

             

            A little while back, we published an example of a systematic approach for duplicating hierarchies of records:

             

            http://www.nightwingenterprises.com/demosX/demoX06.html

             

            It's a free download of the demo, and the method is quite portable, though it does require a few elements to be in place for the script to work, as described in the notes within the demo.

             

            Regards,

            Ray

            ------------------------------------------------

            R J Cologon, Ph.D.

            FileMaker Certified Developer

            Author, FileMaker Pro 10 Bible

            NightWing Enterprises, Melbourne, Australia

            http://www.nightwingenterprises.com

            ------------------------------------------------

            • 3. Re: Duplicating a table with relationships
              TimAnderson

              Kathryn

               

              Ray's technique works really well and fast - and is very portable. Standard in my solutions now

               

              Tim

              • 4. Re: Duplicating a table with relationships
                GaryTate

                This is fine and works, but I use a little trick to save the need to store the original primal key and do the searching, but you've got to be careful. If you Go To Related Records and show only related records in all child tables from the parent before doing anything else, this will get your found sets of related records, then dupe the parent, get it's primary key, go to each child table in turn, dupe all records & set to use the key key.

                 

                Same effect though ;-)

                 

                Gary

                • 5. Re: Duplicating a table with relationships
                  RayCologon

                  user5224 wrote:

                   

                  This is fine and works, but I use a little trick to save the need to store the original primal key and do the searching...

                   

                  Hello Gary,

                   

                  Perhaps you misunderstood the technique I posted a link to. It doesn't store the primary key and there are no searches involved.

                   

                  Regards,

                  Ray

                  ------------------------------------------------

                  R J Cologon, Ph.D.

                  FileMaker Certified Developer

                  Author, FileMaker Pro 10 Bible

                  NightWing Enterprises, Melbourne, Australia

                  http://www.nightwingenterprises.com

                  ------------------------------------------------

                  • 6. Re: Duplicating a table with relationships
                    GaryTate

                    Not replying to your post mate :-)

                     

                    G

                    • 7. Re: Duplicating a table with relationships
                      RayCologon

                      user5224 wrote:

                       

                      Not replying to your post mate :-)

                       

                      G

                       

                      Hi Gary,

                       

                      Thanks for clarifying. The forum does actually say which post you were responding to, but I'm afraid I missed that. :o

                       

                      Regards,

                      Ray

                      ------------------------------------------------

                      R J Cologon, Ph.D.

                      FileMaker Certified Developer

                      Author, FileMaker Pro 10 Bible

                      NightWing Enterprises, Melbourne, Australia

                      http://www.nightwingenterprises.com

                      ------------------------------------------------

                      • 8. Re: Duplicating a table with relationships
                        jgalt

                        RayCologon wrote:

                         

                        A little while back, we published an example of a systematic approach for duplicating hierarchies of records:

                         

                        http://www.nightwingenterprises.com/demosX/demoX06.html

                         

                        It's a free download of the demo, and the method is quite portable, though it does require a few elements to be in place for the script to work, as described in the notes within the demo.


                        I viewed your demo and the technique works great. Can you please answer two questions...

                         

                        1.) Will this technique will work with external table references?

                         

                        2.) When working with a local table, do you have to referece the original Table Occurrence or will this work on a copy?

                         

                        I have experimented with both methods and I cannot get either one to work.

                         

                        Thanks.