5 Replies Latest reply on Jan 12, 2010 1:25 PM by j.wegner

    Exporting a single record



      Exporting a single record


      Hi all,


      I am trying to create a script to move records from one Filemaker File to another FileMaker file to backup old records.


      To do this, I am using a script that looks like this:


      Enter Find Mode

      Set Field - to locate the specific record

      Perform Find

      Export Records - Exports to a file like Transfer.fp7

      Open File -opens the backup DB Backup.fp7

      Import Records

      Close File

      Delete Record


      The problem with this is, depending on the record, some of my fields in the original database may be empty.  When I do the export, it would appear that FMP skips over those fields.  Then, when I try to do the import those fields no longer appear, giving me an error and not importing any of the records.


      Any ideas on how to solve this problem?



      Joe Wegner

        • 1. Re: Exporting a single record

          I'm not sure I follow your script. Here's how I do it on one of my systems:


          #Isolate record in single record found set

          Show All Records

          Omit Record

          Show Omitted Only

          #Perform Script in back up file to import the record.

          Perform Script["MirrorFile"; ImportRecord]


          ImportRecord is a script in the back up file that uses Import Records to import the record directly from the first file, no export records step used.


          Your script seems to export the record to one file and then imports a record from your back up file instead of the back up file importing the record from your original.

          • 2. Re: Exporting a single record

             I come from older FMP versions, my suggestions may work, but be outofdate


            Original Database


            Select Records  (In Org DB)

               Enter Find Mode

               Set Field - to locate the specific record

               Perform Find

               Perform External Script (in Archive DB )


            Import Records  (In Archive DB)

               Import Records

               Perform External Script (in Org DB )


            Delete Records  (In Org DB)

               Delete Records


            • 3. Re: Exporting a single record

              I would offer another alternative to isolate a single record.  And this method works in multi-user mode.  If one doesn't test that someone else hasn't created a new record while you have your single record omitted, when you Show Omitted, the other person's new record can appear in your found set to export.  To eliminate that possibility, use method I learned from JT (-Queue-) and still believe it offers the best protection:


              Freeze Window
              Show All Records
              Omit Record
              Show Omitted Only
              Exit Loop If [ Get ( FoundCount ) = 1
              Go To Record/Request/Page [ Last ]
              Omit Record

              • 4. Re: Exporting a single record

                Good Point!


                I've learned something new! That makes me lean toward another method I've used for Isolating a singe record: use either a find, or a self-join with Go To Related Records, to isolate the record. Other users adding new records won't affect that method.


                In script Form:


                Set Variable [$ID; YourTable:: PrimaryKeyField]

                Enter Find Mode[]

                Set Field [YourTable:: PrimaryKeyField; $ID]

                Perform Find[]




                Set Field [YourTable::GlobalField; YourTable:: PrimaryKeyField]

                commit Record

                Go To Related Records [Show Only Related Records; From table: "SelfJoinTableOccurrenceName" ; Using Layout <Current Layout>]

                • 5. Re: Exporting a single record

                  Thanks guys.  Got it working


                  Using Perform Script to run a script in the backup DB - so that I could directly import from the original file - allowed me to fix the issue.  Thanks for all your help.