1 Reply Latest reply on Dec 14, 2015 2:41 PM by macwombat

    Copy records frome one table to another

    donhoogkamer

      I'm creating an invoice system where I would like to move records from the line items table to an invoice items table. Copying the order table to the invoice table is quite easy using variables. On the order layout I have created a portal where we can enter the order line items. This basically copies the product information from the products table so that the prices and other fields can be customized without editing the original product record in the product table.

       

      Orders <-> Order Line Items

      Invoice <-> Invoice Line Items

       

      It must be unable for the users to edit the invoices for tax authorities purposes. This is why I want it to be copied so users can modify orders as they like but are unable to edit or delete the invoices. I am thinking of a loop for counting the records in the order line items and then copy them? Thing is I can't really understand how to construct the loop if this is the way to go. Hopefully somebody can help me a little, thanks in advance :-)

        • 1. Re: Copy records frome one table to another
          macwombat

          Hi Don.  Here is one way you could do it.

           

          1.  Create an autocreate relationship between OrderLineItems and InvoiceLineItems TOs (table occurrences).
          2.  Create InvoiceLineItems fields as "Auto-enter Calculations" referencing the corresponding OrderLineItems fields.
          3.  On a layout with the OrderLineItems records set the InvoiceLineItems::OrderLineItems foreign key.
          4.  Put step 3 into a looped script to do the same thing for each record in the found set.

           

          I've included a sample file that shows this method.

           

          Hope this helps.  Chris