1 Reply Latest reply on Jan 16, 2015 6:53 AM by philmodjunk

    Copying from Portal A to Portal B - Help with Script

    ScottMerrick

      Title

      Copying from Portal A to Portal B - Help with Script

      Post

       
      Post:

      I've upgraded from FM 6 to FM 13 and need help with updating a script copying three fields in multiple rows from Portal A to new rows into Portal B.I realize that this is not the best structure, but for now want to keep these portals and a script that will copy the data from one portal to the other.

      This is for an invoicing system, where the first portal has the line items (product detail) for a proposed order and the second portal has the line items for a final invoice. Portal A has three fields (Product, Quantity, Price) and Portal B has similar fields (Prod, Qty, Prc). In FM 6, the portals were each in separate files and were shown with data copied via script from one portal to the other while displayed a third file (an invoice detail file).

      In FM 13, each portal has it's own table and layout - Portal A is in "Proposed Sale Line Items Table" (PSLT) and Portal B is Invoice Line Items Table ("ILT"). Each portal is displayed on a third layout/table called Invoice Detail Table ("IDT"). ISLT and ILIT are both related to IDT but not to each other. The IDT layout/table allows creation of new rows in the ILIT portal/table.

      The script that worked in FM 6 is below:

             
      • Go to Layout [IDT]
      •      
      • Go to field [PSLT::Product]
      •      
      • Go to Portal Row [Select; Last]
      •      
      • Set Field [PSLT::gLastRow; Get(ActivePortalRowNumber)] /  formerly Status(CurrentPortalRow)
      •      
      • Go to Portal Row [Select; First]
      •      
      • Loop
      •      
      •   Copy [PSLT::Product]
      •      
      •   Paste [ILT::Prod]
      •      
      •   Copy [PSLT::Quantity]
      •      
      •   Paste [ILT::Qty
      •      
      •   Copy [PSLT::Price]
      •      
      •   Paste [ILT::Prc]
      •      
      •   Go to Field [PSLT:Product]
      •      
      •   Go to Portal Row [Select; Next, Exit after last]
      •      
      •   Exit Loop If [Get(ActivePortalRowNumber) = PSLT::gLastRow]
      •      
      • End Loop

      Any help is greatly appreciated. 

      Thank you.

        • 1. Re: Copying from Portal A to Portal B - Help with Script
          philmodjunk

          Don't see why that would have worked with two portals in version 6.

          There's code (go to field) to put the focus on the portal into which you paste data, but no code to put the same focus into a particular portal row of the portal from which you are copying data.

          and since your focus has to switch back and forth between portal's in this script, go to portal row next won't work, you'll need a counter--in variable or a global field to keep track of what portal row you next need to copy from and you'll need to increment that counter each time.

          There are many alternative methods for copying data from one table to another. Import records can do this all in one script step, followed by a replace field contents operation to update the needed key field so that the new line items match to the correct invoice record. Another option is to pull up a found set of the portal records on a layout based on that table, then loop through them, switching over to a third layout based on the second portal in order to create a new record with this data.

          And you need to get rid of the copy/paste script steps. They silently fail if the field is not present on the current layout, but more importantly, they destroy any data the user may have previously copied to the clipboard before running this script. This can easily be avoided by using set variable to copy data and set field with a reference to the variable to paste the data. (back in version 6, we used set field to set a global field as a way to copy without affecting clipboard data.)