6 Replies Latest reply on Nov 17, 2014 12:27 PM by Mike Duncan

    Import Records (Source) from script

    deninger

      I have created a quick scipt to import records from another file. Essentially this is a scripted data transfer.

       

      The script (as I have it now) cannot be run un-attended because in the Import Field Mapping dialog (see below). I find no way to specify the source database.

       

      // to prepare the database for installation in another store.

      // the data source needs to be specified in the $path variable below

      Set Variable $path; Value:"fmnet:/192.168.10.25/PharmClin" // set to the location of the existing data source.

      Go to Layout ["DUR" (DUR)]

      Import Records ["$path" ; Add ; Mac Roman]

       

      Import.jpg

      Is there any way to select the "Source" from the Import Records script step? Without it, I have to perform the import manually at each point in the script.

       

      Hopefully I am missing something easy or obvious.

       

      Regards,

       

      Mike

        • 1. Re: Import Records (Source) from script
          PSI

          Mike,

           

          Did you open Specify data source, before Specify Impor Order, and put your variable in the File Path List?

           

          FYI: If the file is hosted and part of your solution, i.e. not going to move you don't need to use a variable $Path. Just select the Soure by clicking Add File, then hosts and select it there.

           

          John

          • 2. Re: Import Records (Source) from script
            deninger

            John,

             

            Yes, that would work, but it would also mean that I would have to modify 15+ import script steps to point to the data transfer. I am trying to accomplish this without having to go to those lengths (hence the single $path veriable in the script).

             

            I suspect that because FileMaker doesn't resolve the path until the script is running, it cannot ascertain what tables exist in the file and therefore doesn't offer the ability to select the source table.

             

            Is there some kind of work-around with this?

             

            When I query data from SQL Server by ODBC, I can specify the data source in the SQL. Is there a way (specifically, an ODBC driver) for MacOS to access FM Pro? That may be a feasible option. Looking at the FileMaker support website, it shows drivers required to access many ODBC data sources, but it does not list supported drivers for FileMaker AS the ODBC source.

             

            Mike

            • 3. Re: Import Records (Source) from script
              PSI

              Mike,

               

              Right you will need to select the file manually to setup the import. Then replace it with the variable.

               

              You only have to set it up once. Bite the bullet and setup the 15 scripts. How long could it really take?

               

              John

              • 4. Re: Import Records (Source) from script
                deninger

                John,

                 

                Maybe I am missing something here.

                 

                If I set up the import (once for each of the 15+ import script steps) in the script by selecting a LOCAL hosted file on (say my test server) and then also add the $path file, it will remember the Source attibute if it cannot find the LOCAL hosted DB and fall back to the $path representation of the file when the script is run off-site (at an installation)?

                 

                Mike

                • 5. Re: Import Records (Source) from script
                  PSI

                  Don't leave the Local path. Replace it with the variable $Path.

                   

                  I do this all the time when i setup imports, generally when a client has data to import where the file name isn't consistent.

                   

                  John

                  • 6. Re: Import Records (Source) from script
                    Mike Duncan

                    When adding the file path, each line (delimeted by return) is the order to try to find the file. If you have a local path listed second, it will allow you to develop and set the import order you would like, but when the script it run and the local variable resolves to the path of the real file, it should match up.

                     

                    Here is a blog post with more details.

                     

                    Thanks

                    Mike