3 Replies Latest reply on Dec 7, 2010 9:17 AM by philmodjunk

    Copy records between portals

    paolobkk

      Title

      Copy records between portals

      Post

      ok this is a bit complicated,

      I have 4 tables:

      "incoming invoice" - with a primary ID key related to "stock bond" (ID = invoice number)

      "stock bond" - with a primary ID key related to "line from bond" (ID = nr entry in bond)

      "line from bond" - with a foreign ID key coming from "line from bond" as described above and also with another foreign ID key coming from "transfer orders" (ID transfer)

      "transfer orders" - (mentioned above) with a primary ID key related to "line from bond"

      I have a layout from "incoming invoice" with a portal for the "stock bond" and another layout from "transfer orders" with a portal from "line from bond".

      When I make a new "transfer order I need to copy all the items from the portal of "incoming invoice" layout (table: stock bond)  to the portal in the "transfer order" layout (table: line from bond).

      After few days of trying and scripting I still can't get it to work, perhaps somebody have some ideas?

      Thanks Smile

      fm.jpg

        • 1. Re: Copy records between portals
          philmodjunk

          Starting from Invoices this script should do the trick: (I'm assuming you want to create a new, matching Transfer Order record each time)

          If ( Not IsEmpty ( Stock Bond::Invoice number ) /* make sure that there are records in the portal */]
              Freeze Window
              Set Variable [$InvoiceID ; Value:  Invoice_ID]
              Go To Layout [Transfer Orders]
              New Record/Request
              Set Variable [$TransID ; value : Transfer Orders::ID Transfer ]
              Set Field [ Transfer orders::Inc Invoice number ; $InvoiceID ]
              Go To Layout [original layout]
              Go To Related Record [ show only related records ; from table: Stock Bond ; using Layout: "Stock Bond" (Stock Bond ) ]
              Loop
                  Set Variable [$BondID ; Value: Stock Bond::Id Entry in Bond]
                  Go To Layout [ Line from bond ]
                  New Record/Request
                  Set Field [ Line from Bond::Transfer order ; $TransID ]
                  Set Field [ Line from Bond::Id Entry in Bond ; $BondID ]
                  Go To Layout [Stock Bond]
                  Go To Record [ Next ; exit after last ]
              End Loop
              Go To Layout [original layout]
          end If

          • 2. Re: Copy records between portals
            paolobkk

            Wow!!

            That was awakening! Surprised Thanks, It worked at the first shot and I'm still studying all the connections between variables, records and layouts.

            Just now is getting more clear! :)

            That was a great help, Thanks again!

            • 3. Re: Copy records between portals
              philmodjunk

              Understanding the connections between table occurrences in your relationship graph, the table occurrence specified for each layout and how you can use this to control which record's data may be accessed by your script is key to getting more power from your scripts. Keep plugging and don't hesitate to ask qestions if there's something you don't understand.