7 Replies Latest reply on Jan 23, 2012 3:08 PM by silba2021

    Help with import script



      Help with import script


      I am trying to import a found set into my solution from another filemaker file using a script.

      I have set up the script to open up the file I am going to import from but since the opened file is not the file that is running the script I cannot do a find to get a found set. Is there a way to run a script on the opened file to get a found set before importing it into my solution.

      Both, my solution and the one that I want to import from have the same field names. Would appreciate any help Thanks.

        • 1. Re: Help with import script

          Set up a script in the source file to find the records you want.

          The set a script in the destination file that calls that Find script, which effects the find.  Then the script's next step returns to the destination file and does the import.

          • 2. Re: Help with import script

            Thanks Sorbsbuster,

            I did not realize that perform script could call scripts from another file.

            Still having a problem though, I have set the import to only existing records and add new records, but it seems to import all records in not just the found set. The constraining the data seems to be working fine, so I am not sure what the problem is.

            • 3. Re: Help with import script

              Test the Find script in the originating file first.  Does it find the records you want?  If not, go no further until you've de-bugged that.

              Set the second script to just do the import (ie: not stringing them both together).  Set the import options to be what you intend.  They are:

              - overwrite the existing records in the destination file with the imported data
              - add new records, of the imported data, to the existing records in the destination file
              - update the existing records with the data in the source file, by matching some field(s) that you specify.

              After you get it to import correctly, make the running of the first script a step in the second script.

              • 4. Re: Help with import script

                And check your found set in the target table. If you are using the import matching option to match to specific records or import existing to overwrite records in the target table, keep in mind that these options apply to your current found set. Often, you need to do a show all records before performing such an import so that all your existing records are part of your found set.

                ("Target table" means the table receiving data during the import records process.)

                • 5. Re: Help with import script

                  Ok, to make things less confusing I duplicated my file, added "source" and "target" to each of the file names. To the source file I made some data changes to existing records and added some new records.Created a found set (records created in 2012).

                  In the target file I did a show all records and then a import of the source file, set to update matching records and add any new records. Each time it goes through and imports all the records from the source file. The matching field is a unique serialized ID. When I check the "Perform auto-enter options", it duplicates all the records.

                  Which in itself is not a bad thing since I am trying to sync records in both files but there will be about 60 K records and it is too time consuming to import them all each time(especially since older records will not see changes).

                  • 6. Re: Help with import script

                    Created a found set (records created in 2012).

                    Did you leave the source file open at this point?

                    Import records from a closed file imports all data in the source table so this is one possible explanation if you closed the file after setting up your found set.

                    Did you import from the same table occurrence as the table ocurrence of the layout where you set up your found set? You can have multiple table occurrences for the same table and each has their own found set so this is another possible reason you are importing all records in place of the found set.

                    • 7. Re: Help with import script

                      OK that fixed it. I made the mistake of assuming since both files were on the same layout the import window would use the same table occurrence. Should have paid more attention to the dropdown in the import window. Thanks a lot.