5 Replies Latest reply on May 13, 2015 8:56 AM by philmodjunk

    Help creating a script



      Help creating a script


      I'm needing help creating a script.  I need to take each record in my database and export them out individually as XML - that is, each record will have it's own XML.  


      The XML will need to be named after the data in one of it's respective records field.  'For example, one field is called Tape_Number, and the data in the record is INT001R.  The xml of this one record would need to be named INT001R.xml.

      Hope that makes sense - thanks!

        • 1. Re: Help creating a script

          Export Records can export XML. But it exports all records in your found set so to export just one record, you need to isolate that one record in a single record found set.

          When you set up export records, you can set it up to refer to a variable instead of an explicit filepath and file name.

          You can thus use set variable to set a $Path variable to the file path and file name--which can refer to your text field in order to name the file.

          For more on $Path variables and the script steps that can use them: Exploring the use of a $Path Variable in Scripts

          Caulkins Consulting, Home of Adventures In FileMaking

          • 2. Re: Help creating a script

            Thanks for the Path variable demo, so far I got that to work.

            The challenge I'm facing now is simply going through each record, one by one, and isolate them for the export. I can isolate one asset, but I can't move to the next one in line (such as Go To Record with the NEXT option) and isolate that asset, then so on and so forth.

            • 3. Re: Help creating a script

              Unless there's an easier way, maybe open up second window, isolate, export, close window.  Go to next record, open up second window, repeat.  I would make the layout for export only contain the fields needed

              • 4. Re: Help creating a script

                Awesome - that worked!  Last thing.  It seems on my XML export settings have to be confirmed every time during export, even though they are set in the script.  Is there any way to avoid that?

                It asks me to specify the XML and XSL Options and Field Order for each export, even though I already did that.

                • 5. Re: Help creating a script

                  Did you select the "perform without dialog" option for Export Records?

                  And alternatives to two windows:

                  Create a second layout based on a different table occurrence (box in Manage relationships) that refers to the same base table (also called a data source table). The found set on each layout is then independent and you can use one layout for your found set of records to export and the other to isolate one record at a time for the export.


                  Just capture the Unique ID's of each of your records in the initial found set in a variable. The "list of" summary field in FileMaker 13 or later comes to mind as a simple way to get that list to set a variable. Then you loop through the values in the variable instead of looping through records in a found set.