2 Replies Latest reply on Jan 6, 2009 8:46 AM by jwagner

    Best way to duplicate record + related records?

    jwagner

      Title

      Best way to duplicate record + related records?

      Post

      My FM database has the following structure:

      QuoteHeader

      QuoteLines

      QuoteSubLines

      Each quote my users create will have at least 1 QuoteLine record, which in turn will have at least 1 QuoteSubLine record.  My users want to be able to replicate an existing quote into a new quote record, including the lines and sub-lines, as this would save a lot of data entry.  What is the best way to script this?  (I'd like to have a button on the quote screen that would copy the data from the current record into a new record, with a new quote number).

        • 2. Re: Best way to duplicate record + related records?
          jwagner
            

          -------- Pasted from referenced thread -----------------------------------

          You have a table MAIN and show a portal of table RELATED and want to duplicate one record of MAIN with all his children in RELATED, right?

          You need a script like this

          Go To Layout [ MAIN ]
          #
          # Search by relationship of all the children
          Go To Related Records [ RELATED ; show only matching ]
          #
          # Jump back
          Go To Layout [ MAIN ]
          #
          # Duplicate MAIN Record and store ID
          Duplicate Record
          Set Variable [ $ID ; MAIN::ID ]
          #
          Go To Layout [ RELATED ]
          #
          Loop
          End Loop If [ Get( FoundCount ) = 0 ]
          Go To Record [ First ]
          Duplicate Record
          Set Field [ ID_Main ; $ID ]
          Omit Record
          Go To Record [ First ]
          Omit Record
          End Loop
          #
          Go To Layout [ MAIN ]

          Jens
          ---------------  End of cut/paste -------------------

           

          Jens - thanks for your quick reply. Using the Omit Record command hadn't occurred to me.  I'll give it a try.

           

          John