8 Replies Latest reply on Oct 11, 2016 3:58 PM by philmodjunk

    import script

    MacDevGuy

      I want to write a script that imports a record (or records) and then updates that record in another Filemaker db (It's a duplicate of the same db).

       

      I would likely use the primary key of the contact and also match by first name and last name.How scriptable is Filemaker Pro when using AppleScript?

      Or could I script this entirely in Filemaker Pro having it find the record then update the record?

      Does anyone know of any working examples using this technique I could look over?

        • 1. Re: import script
          philmodjunk

          You can script this entirely in FileMaker.

           

          If your primary keys are true primary keys, you should only match records by the primary key, not also by the name fields--they might even be what has been updated if a name was originally mis-typed and has now been corrected.

           

          I suggest researching the Import Records script. You can use it to import the current found set of records in one table into another table and there's an option for matching records that you can use to match records by primary key fields.

          1 of 1 people found this helpful
          • 2. Re: import script
            synergy46

            I've been using the 360 Works plugin for over a year in my import routine.  It seems to really simplify the path creation for Windows and Mac OS's and with a little 'nudging', it works pretty well.   (plus it is free)

            360Works ScriptMaster: Free FileMaker Modular Plugin

             

            The below script is the first of two scripts.  The one below is the first one and after it establishes the proper path, filename etc it calls the Import_GTE_ 900 script which does the actual opening of the layout, deleting of records and the importing.

             

            Hope this helps

            IMPORT75.png

            • 3. Re: import script
              philmodjunk

              Many of us could provide you with working examples that import records, both with and without the use of plug ins. But all would have to make a lot of guesses as to what you are actually trying to accomplish since there are a lot of variables not documented here such as:

               

              Why you want to do this in the first place

              Whether the target file will always have the same name and location

              Whether both files will always be open and can be always linked via an external data source reference or whether one copy is "off line" on a lap top or mobile device with periodic "synchs" back to the "mother file"

               

              It's even possible that no such import at all is the best solution since there are ways to use a Progressive Back up in FMS 14 and 15 to set up a "fail over" server with the same data as the active server.

              • 4. Re: import script
                MacDevGuy

                Phil,
                3 people share a database. One made some updates. He's not supposed to do that. In an effort to consolidate I exported them back when I didn't understand the ramifications of exporting a category field with repeating values to Excel. So on a small sample I lost some of the repeating values. I know that I can probably edit these in less time than it would take to figure all this out but I want to understand how to do it. I want to re-import the records from his copy 'PRE export' to excel and use the 'update records' option. Make sense?

                 

                The repeating values are things like "Friend" "Business" "Surfing" "Bowling". After the export to excel additional selections were lost but I didn't realize it.

                • 5. Re: import script
                  philmodjunk

                  If there is a field, such as the primary key exported that uniquely identifies each record, then for most of your data, you could show all records in FileMaker and then use the update matching records option while selecting the "unique identifier" field as the match field.

                   

                  But importing into a repeating field will be a problem. Off hand, the only approach that sounds workable would be to import the data into an intermediary table and then use a script to move the data into different repetitions of that repeating field.

                  • 6. Re: import script
                    MacDevGuy

                    philmodjunk wrote:

                     

                    ...importing into a repeating field will be a problem. The only approach that sounds workable would be to import the data into an intermediary table and then use a script to move the data into different repetitions of that repeating field.

                    Actually Phil that's exactly what I would like to do. I have known for a while the problems that repeating fields can present and my future goal is to get the contact categories into a join field then display them in the contact with a portal. My guess was that this goes beyond merely importing and updating the records. So maybe I am asking the wrong question? Maybe the question should be: How to break out a repeating field into separate records? I am going to do a search of the KB and see if I can find something on that topic.

                    • 7. Re: import script
                      MacDevGuy

                      A-HA! Look what I just found. Converting repeating fields to portals | FileMaker

                      (You probably already knew about this.)

                      • 8. Re: import script
                        philmodjunk

                        Yep, splitting repeating fields into a related table of records has been a very useful feature since Filemaker 3 first introduced relationships and portals.