4 Replies Latest reply on Apr 25, 2011 2:33 PM by mgores

    Copying portal records



      Copying portal records


      In my quote system I have two portals to LineItems on the entry layout.  One portal is to enter the line items into with  Qty, Description and price fields, with allow creation of new records.  The other portal is showing past line items for that customer, in decending order of quoteID and the current quoteID filtered out. 

      I would like to be able to click on a portal row in the Past line items portal and have a new record created with the same Qty, Description and price, but with the new quoteID.  Is there a simple way?

        • 1. Re: Copying portal records

          I'm going to assume that the table occurrence for you "past items" portal, is named PastLineItems adn your new portal is named LineItems. Just subsitute the actual names for mine in the following script:

          #This script should be performed by clicking a button in the PastLineItems portal.

          Set variable [$Item ; Value: PastLineItems::ItemID]
          Set variable [$Qty ; Value: PastLineItems::Qty]
          Set variable [$QuoteID ; Quotes::QuoteID ] //am assuming current layout is based on Quotes table occurrence
          Freeze window
          Go To layout [//select layout based on line items]
          New Record/request
          Set Field [LineItems::QuoteID ; $QuoteID ]
          Set Field [LineItems::ItemID ; $Item ]
          Set Field [LineItems::Qty ; $Qty]
          Go To layout [original layout]

          Description and Price should come from a Products table that is related to LineItems so I don't think you'll need to copy them over as copying over the Item ID should be sufficient to link the Line Item record to a Products Record.

          Note: You can either place a button inside the portal row or you can select all the fields in the portal row and use button setup... to turn them into a button. Either way, the mouse click on the button, both puts the focus on the selected portal row and performs the above script.

          • 2. Re: Copying portal records

            Phil,  actually the services we are quoting are pretty much custom every time so there is not a product table, just the line item table, with those 3 fields (plus the key field and a couple of calculation fields used for other purposes).  There are two table occurences for the line item table, Lineitems and Lineitems 2.

            So what I am getting is that I need to go to a Lineitems layout, create a duplicate record except using the new quoteID, then back to the original layout.  Correct?

            • 3. Re: Copying portal records

              Yes, and you can then bring along the additional data in additional variables here. You could do this with by interacting directly with your portal, but I prefer to go straight to the portals table as it is less likely to be affected by future changes to your layout.

              Your wording just sparked an idea for another approach if your two portals are to the same data source table:

              Set Variable [$QuoteID ; Quotes::QuoteID]
              If [ Not IsEmpty ( PastLineItems::ItemID /* There is a record in the portal to select */]
                 Freeze Window
                 Go To Related Record [Show only related records; From table: PastLineItems; Using layout: "lineItems" (lineItems)]
                 Duplicate Record
                 Set Field [LineItems::QuoteID ; $QuoteID]
              End If
              Go to Layout [Original Layout]

              • 4. Re: Copying portal records

                I like that idea, should run pretty fast and be nearly invisible to the user.