1 Reply Latest reply on Aug 20, 2015 6:35 AM by philmodjunk

    Scipt question : copying data from one field to another using a script

    GregSnell

      Title

      Scipt question : copying data from one field to another using a script

      Post

      HI.

       

       

      I am new to FM, trying to use a button with a script to add data from a field on a selected line in a list layout, and add then input that data into a specific field on a form layout.   What is the best way to do this via a script ?

      Example is I am looking at a Catalog item and want to copy the catalog number into a purchase sales form.

       Any ideas would be greatly appreciated!

      Thanks!

       

       

        • 1. Re: Scipt question : copying data from one field to another using a script
          philmodjunk

          It's not that you have different layouts, but that you have fields from different tables. And with a "purchase sales form", you might have two tables and multiple records displayed on that form as the typical sales invoice uses one record for the invoice and a set of related records for listing each item purchased on that invoice--typically those items are listed in a portal.

          So your script might need to do more than just copy the data to a field on the other layout, it might need to modify this value on a specific record on that layout. The following script assumes that you have the typical data model for an Invoicing system:

          Invoice----<Invoice Data (line Items)>-------Products

          Your "catalog" would likely be based on Products.

          The following script creates a new record in Invoice Data and sets its product ID field when you click a button on a layout based on Products.

          Set Variable [$ProductID ; Products::__pkProductID ]
          Go to Layout ["Invoice" (Invoice) ]
          Go to Object ["LineItemsPortal" ]---> use the inspector to give an object name to the portal
          Go to Portal Row [Last]--This only creates a new record if "allow creation of records via this relationship" is enabled for InvoiceData
          Set Field [InvoiceData::_fkProductID ; $ProductID ]