5 Replies Latest reply on Aug 12, 2015 3:09 PM by AndrewCrisford

    Duplicate Record then change field



      Duplicate Record then change field



      Ive been trying to get my stock table up and running, and I feel so close to getting it all set up. 

      Theres just one thing that isn't working, which is a part in the script where I need to duplicate a record then change the location in and supplied from fields of that newly duplicated record. It seems to be changing on the original record instead. 

      Ive added a picture if that helps

      Thanks a lot in advance!



        • 1. Re: Duplicate Record then change field

          Remove line 8 (love those line numbers in the new workspace!)

          The duplicated record will be the current record immediately after line 7 executes.

          Lines 9 & 10, however do not look correct. They will set their target fields to the value of either 1 or 0 depending on whether the value of the two referenced fields in the calculated result are equal (1 ) or not equal (0).

          • 2. Re: Duplicate Record then change field

            Thank Phil!

            So I've removed line 8 and changed 9 to Set Field [ Inventory::Location ; Stock Transactions::Location In ] and 10 to Set Field [ Stock Transactions::SuppliedFrom ; Stock Transactions::SuppliedFrom ]. That is the correct format right? 

            I guess since the Duplicate Record function makes the duplicated record the current record, the Set Field functions will be taking values from the newly duplicated record. 

            Is it possible to copy to clipboard two field values before the duplicate record function, and then paste them after the record function?

            • 3. Re: Duplicate Record then change field

              Yes, but don't.

              Use variables to store those values instead.

              copy/paste will destroy any data a user might have copied previously to the clipboard. They tend to get confused and upset when they copy data, then run a Filemaker script and the data they copied is mysteriously replaced by other data copied by your script.

              Also the duplicated record will be a duplicate of the original except for certain auto-entered values. So in many cases, the data from a related record will still be accessible from the duplicated record--but not if the relationship is based on an auto-entered primary key that is now different in the duplicated record.

              • 4. Re: Duplicate Record then change field

                Hmm ok, 

                So I've got Set Variable [$LocationIn ; Value: Stock Transactions::Location In] which occurs before the Perform Find function

                Then use Set Field [Inventory::Location ; $LocationIn ] which occurs after the duplicate function

                Would this potentially have problems if the location field is part of a value list, which allows user entry of other values?

                • 5. Re: Duplicate Record then change field

                  opps, ignore line 14, i will delete that now