5 Replies Latest reply on Apr 17, 2012 12:38 PM by Stephen Huston

    Scripts for exporting and exporting data

    christopherc

      I am trying to write a script that would export all data in each table in a Filemaker file to import into a clone of the file. I am exporting to a separate .fp7 file for each table. I am using the 'go to layout' and 'show all records' script steps, followed by the 'export records' step. I have enabled the 'specify output file' and 'specify export order' options. When I run the script, the 'specify field order' defaults to 'current layout'. How do I setup the script so that the default is 'current table'?

       

      As for the import side of things, the option will always be to 'add new records' since I am importing into a clone, which Filemaker defaults to since each table is empty. How do I get the import step to default to arrange by matching names? It defaults to 'last order'. I want to be able to run both scripts without dialog since there are a number of tables that I need to export and import.

       

      Thanks,

      Christopher

        • 1. Re: Scripts for exporting and exporting data
          Stephen Huston

          My experience has been the field matching order is preserved if you specify that it use no dialog.

           

          I also recommend that each import and export be within it's own script so that no script contains more than one saved field matching order. This used to be critical, and I have kept the habit, though it may not be as important in recent versions.

           

          Then call each script in order from a master script which goes to the correct layout before calling each import/export.

           

          Scripts set with a single import/export order and performing them without dialog should retain their stored settings. If you examine the dialog, FM assumes you are going to edit it, often defaulting to last used, whcih may not be the order for that script.

          • 2. Re: Scripts for exporting and exporting data
            christopherc

            Thanks for your help Stephen. I did an export for each table manually and then created the export scriptstep with the 'no dialog option' and was able to run the exports successfully. I already had a single script to do all of the exporting so I replaced the export steps in the single script and used that. The key was using the 'without dialog' option. Now I'm going to work on the import side to see if I can successfully import all of the exported tables into a clone. Thanks again.

             

            Christopher

            • 3. Re: Scripts for exporting and exporting data
              Stephen Huston

              Sounds like it's working, and the imports should behave similarly.

               

                   One additional GOTCHA for down the road. When working with no-dialog imports and exports, FileMaker has one nasty habit that has bitten me more than once: I forget about the imports and exports that have ben working just fine for months or years, and then I update the system, and remove an obsolete field that is not longer referenced anywhere in the entire DDR. Sounds safe....

                   However, if that file was created earlier than the newest field used in an import or export, the fields in the stored imports/exports reposition themselves incorrectly when run from then on, until you reset them in the script(s).

                   FileMaker has been told of this problem, but it continues thru FM11. (Have not gotten around to testing this in 12 yet.)

                   So be careful when updating schema with supposedly-safe modifications. If the changes will affect the underlying order or creation position of fields used in script imports and exports it can befuddle your saved field matches.

              • 4. Re: Scripts for exporting and exporting data
                christopherc

                thanks for the GOTCHA. I just had to add new fields to 6 tables so that came in very handy. I went to each of the layouts and performed and export and import, and updated the script steps after each. I'm still a bit confused as to wheter I need to do that in the layout firest, or if I can just update the script directly by making any changes necessary.

                 

                Thanks,

                Christopher

                • 5. Re: Scripts for exporting and exporting data
                  Stephen Huston

                  You can update the scripts directly without having to perform the newly-reordered import manually.