3 Replies Latest reply on Feb 19, 2015 9:33 PM by bladeomatic

    What is best apporach to duplicate a set of nested portals

    mark_b

      Greetings,

       

      I can't get my mind around this like I used to.  I have a parent record that has related records displayed in portal-A.  By using OnObjectEnter script triggers, when a row is selected in Portal-A, another set of records related to the Portal-A record are displayed in Portal-B.  And again, when a row is selected in Portal-B, a 3rd set of records related to the Portal-B records are displayed in Portal-C.  None of the portal tables will have more than 10 to 15 related records.  What needs to happen is to duplicate the original parent record and duplicate all of the children in the related portals.  I think this will involve 3 nested loops, where I get the UUID of the parent, duplicate or export/import each level of children and update/replace the links to prior level.  But this is where I bog down.  In theory it sounds easy, but the execution eludes me.  I have seen examples where a blank global field is included in a relationship - what some call an "Obligatory Create", and a loop walks through one set of children and creates duplicates by clearing the global field at each loop iteration and setting a field in the child table.  But then how do I use that technique to duplicate the children from the records that were just created. I feel that an export/import would be better because I could use the replace field option for the related key values.  I feel I'm going in circles and becoming a bit loopy.  Any guidance would be much appreciated.

       

      Regards, Mark

        • 1. Re: What is best apporach to duplicate a set of nested portals
          CarlSchwarz

          You don't want nested loops, just go to each table, find the records that relate to your A primary key (A_UUID) and then perform whatever operation you wish.

          A bit of pseudo-code below.

           

          set variable $A_UUID = A_UUID

           

          Go to layout A

          enter find mode

          set field A_UUID  = $A_UUID

          perform find

          duplicate record (or whatever you want)

           

          Go to layout B

          enter find mode

          set field A_Table::A_UUID (follow your relation to the A table)  = $A_UUID

          perform find

          if(getlasterror) = 0

          loop

          duplicate record (or whatever you want

          go to next record

          end loop

           

          Go to layout C

          enter find mode

          set field A_Table::A_UUID (follow your relation to the A table)  = $A_UUID

          perform find

          if(getlasterror) = 0

          loop

          duplicate record (or whatever you want

          go to next record

          end loop

          • 2. Re: What is best apporach to duplicate a set of nested portals
            wimdecorte

            another approach is to to do Go To Related, export to an intermediate txt file and import it back then process the imported records.  Depending on the size of your record sets that may be faster / easier

            • 3. Re: What is best apporach to duplicate a set of nested portals
              bladeomatic

              What Wim said.

               

              Imports are generally the fastest way to create records in FileMaker solutions. I have a method I came up with to duplicate a found set of invoices AND their related line items using imports and some creative field mapping. It's extremely fast, taking about 2 seconds to duplicate one thousand invoices with their line items.  This isn't exactly what you're trying to do, but many of the priciples can be used in your situation. Email me privately if you'd like to play with the example file.

               

              David A. Knight

              President

              Angel City Data

              Platinum Member, FileMaker Business Alliance

              2014 Excellence Award Winner "Design of the Year"

              2009 Excellence Award Winner "Business Partner of the Year"

              2001 Excellence Award Winner "Outstanding Technical Support"

              dknight@angelcitydata.com

              www.angelcitydata.com

              **************************************************