4 Replies Latest reply on Jul 22, 2014 10:44 AM by philmodjunk

    Importing records between tables in a file on a server

    VirginiaPollard

      Title

      Importing records between tables in a file on a server

      Post

           I want to use Import Records in a script to move data from a found set of records in one table into new records in another table in the same file.

           This works perfectly in a test sample script I wrote using a clone of the main FMP file on my local PC. But the file I actually want to use this script in is on a server and is sometimes shared. When I try to run the script on this file, I get an error message at the import step, saying that the file is already in use and can’t be opened (yes, it’s in use by me.) 

           The only difference between the script that works and the one that hangs appears to be the location of the file (local vs server.) Is there a way I can get around this problem? Thanks!

        • 1. Re: Importing records between tables in a file on a server
          philmodjunk

               Do this:

               Open the hosted copy of the file.

               Open this script in Manage | scripts

               Edit the import records script by re-selecting the file and table from which you want to import the data. When you select the file, use the Open Remote option so that this reference correctly accesses the hosted copy of the file.

          • 2. Re: Importing records between tables in a file on a server
            VirginiaPollard

                 This works fine, except that I want to import data from a found set of records. (My script finds the set and later uses Import Records to bring the desired data from this found set into the other table in the file.) When I follow your suggestion, the script imports the data from a different instance of the file on the server and inserts data from all records in the hosted file—not just records that are in the found set in the file instance I have open. Is there a work-around for this?

                 Thanks again.

            • 3. Re: Importing records between tables in a file on a server
              RickWhitelaw

                   "the script imports the data from a different instance of the file on the server"

              What does this mean exactly?

              • 4. Re: Importing records between tables in a file on a server
                philmodjunk

                     If the client has both files open at the time of the import, Import records imports the found set. If the client does not have the source file open, import records imports all records from the specified table. Thus, have your script open the file using Open File or Perform script [specify a script in the source file here] to open that file before importing from it.

                     Like Rick, I really don't know what you mean by a "different instance of the file". One should not have multiple copies of the same file open on the server, the resulting confusion could be disastrous. If you mean a different instance of a particular table, each such instance, also called a table occurrence, has it's own unique name in Manage | Database | Relationships. You can thus set up the Import Records step to import from a specific table occurrence by selecting that specific table occurrence by name from the source table drop down list.