7 Replies Latest reply on Aug 17, 2009 10:24 AM by philmodjunk

    Copying a record and its portal issue

    donjuancarlos_1

      Title

      Copying a record and its portal issue

      Post

      I have a button set up that allows users to copy an existing purchase order (and its line items) to a new purchase order.  I use the method that uses exporting to and importing from a temp.tab file. Here's my issue:

       

      - The Line items database uses lookups from a Catalog database to retrieve the price of an item.

      - The user can change that looked-up price.

      - When the user clicks the "Copy PO" button,  Filemaker exports an imports the line itemsl; but then afterwards, re-performs the lookup and changes all of the prices to their default values. :(

       

      Is there any way to prevent Filemaker from performing the lookup when I am copying a PO?

        • 1. Re: Copying a record and its portal issue
          philmodjunk
            

          During imports you can disable the auto-enter actions, but export then import seems way to complex for this need.

           

          Try using "duplicate Record" instead.

           

          You can use a find or Go To Related record to isolate your record to be duplicated, duplicate the record and then return to your original layout.

           

          Note of Caution: Go To Related Record can fail to work correctly under circumstances where there are no related records or (as in this case) the user might accidentally trigger the script from the bottom, blank portal row. If you use GTRR, add a check to avoid these possibilities.

          • 2. Re: Copying a record and its portal issue
            donjuancarlos_1
              

            Oh man, I was looking all over for the option and found it only appears after you press OK in the Import Field Mapping dialog box. :smileytongue:

             

            As far as using export/import goes, I probably wasn't clear enough in my post--I am copying the entire PO.  I use Duplicate Record for the main record, and Export/Import for the line items.

            • 3. Re: Copying a record and its portal issue
              philmodjunk
                

              You might still find duplicate record as the simpler way to go.

               

              You can isolate the related records in a found set and loop through them duplicating (and updating the matching keyfield so it links to the newly duplicated parent record) each one in turn.

              • 4. Re: Copying a record and its portal issue
                donjuancarlos_1
                   I may have to go that way at some point, as export/import is not web-publishing compatible....
                • 5. Re: Copying a record and its portal issue
                  mrvodka
                    

                  Here is a sample script that will duplicate your parent record and its children.

                   

                  Freeze Window

                  Unsort  // added due to autosort in FM10

                  Set Variable [ $recordnum; Get ( RecordNumber ) ]

                  Duplicate Record/Request

                  Commit Records [Skip Validation; No Dialog]

                  Set Variable [ $parentID; pkParent_ID ]

                  Go to Record [ $recordnum ]

                  If [ not IsEmpty ( pkChild_ID ) ]
                     Go to Related Records [ Show Only Related Record; From table: "Child"; Using Layout:: "Child Layout" (Child) ]

                     Loop
                     Exit Loop If [ fkParent_ID = $parentID ]
                       Duplicate Record/Request
                       Set Field [ fkParent_ID; $parentID ]
                       Go to Record [ First ]
                       Omit Record
                     End Loop
                     Go to Layout [ Original ]
                  End If

                  Go to Record [ Last ]

                  Sort // optional sort if you want it to sort back to the way it was.






                  • 6. Re: Copying a record and its portal issue
                    donjuancarlos_1
                      

                    So the blessed Duplicate Record command re-performs lookups and there doesn't seem to be a way to shut it off. 

                     

                    How would you do this script if you wanted to retain the original data?  As far as I can tell you would have to creat a new record, then copy and paste all of the fields from the old record to the new record...

                    • 7. Re: Copying a record and its portal issue
                      philmodjunk
                         Only the auto-entered serial number will change and this is desirable behavior in almost all cases. All other fields should remain unchanged and wont need to be "copied over from the original".