9 Replies Latest reply on Jan 8, 2012 5:22 AM by FranzLang

    Duplicating Portales



      Duplicating Portales


      We have developed a Music Publishing program where we have come accross a problem where more than one of our writers have written several songs together.  The information will be exactly the same on all of these songs except for the title.  We need to be able to duplicate all of the information onto a new record, except the title, at the same time we need to have a new songID number.


      Is there a way to duplicate the information from the portal into a new record with a new number?  We also need to be able to do this with our billing invoices, since our billing invoices sometimes need to be sent to as many as 5 or 6 different companies with the same information.


      Thanks for your help

        • 1. Re: Duplicating Portales
          Jens Teich
             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 ]
          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 ]


          • 2. Re: Duplicating Portales
               Thanks, I'll give it a try.
            • 3. Re: Duplicating Portales

              I Know it's been quite awhile since I've sent this, and, believe me, I've tried this sooo many times, but some of the steps that you put in there I just don't understand and therefore I just can't get it to work.  For instance, I don't know how to go about storing the ID, nor do I know what "jump back" means.


              Can you explain it to me like I'm a two year old?



              • 4. Re: Duplicating Portales

                The lines in the script that start with # are comments. They explain what steps follow.


                So all you really need to do is to reproduce the other lines in the order given and the script should work.

                • 5. Re: Duplicating Portales

                  Thank you!



                  • 6. Re: Duplicating Portales



                    Thanks for the script. I have one problem, and that is that the new record has the same ID number as the original, so that if there were two related records, I now have two identical main records with 4 related records in each rather than 2 records with 2 records in each. Am I missing a step of where I can change the id number for both the main record and for the related record? Thanks for your help.

                    • 7. Re: Duplicating Portales

                      You're ID field should be set as an auto-entered serial number. Then, the duplicate record step should copy all values except in the ID field--which will receive a new unique ID number.


                      In reading this thread, I have to wonder if life wouldn't be a lot simpler for you if you created a join table or two intead of duplicating so many records. It seems possible that you have some many to many relationships here.

                      • 8. Re: Duplicating Portales


                        Jens' script works great for me also.

                        I am using it to duplicate my Invoices and their related LineItems.

                        However, one little problem is that the "Amount" field of each LineItem is not duplicated properly. Instead, it is always set to "1", no matter what the original value is.

                        I figured myself that this is because I have "1" as an Auto-Enter value.

                        But how can I override this default and write the correct Amount into the duplicated LineItem?

                        • 9. Re: Duplicating Portales

                          Nobody can help me out here?