1 2 Previous Next 18 Replies Latest reply on Mar 21, 2012 11:46 AM by philmodjunk

    Import script steps

    JCPython

      Title

      Import script steps

      Post

      I am not sure if this is possible, but i have my database that i would like to have a button called "import" which would import the records through script step im guessing, grabbing the records from a complete different database file, its a .USR file. the fields are all similar between the two databases but named very differently, users importing records from the foreign database will more then likely not like having to match all the fields up between both databases to import their records, seeing as the users who will have this older database will only be importing into my new database the matching fields would be the same.

       

      i figured if i could just have them all matched up myself and then users could just push the button and boom, all their many records are imported without them having to see all the technicle stuff.

       

      i see the script step for "import" but when i get to the specify import order section i cant see a way to set up a way to keep the import settings so that whatever i set for matching fields it will do the same automatically for the users when they click the button, provided that the foreign database to import from is in the same path as set in the specify path part of the script step, i feel like im not making sence, please let me know if this is clear

        • 1. Re: Import script steps
          philmodjunk

          I'm not sure where this is failing for you.

          when you add the import records step, you have controls at the bottom right of the script editor window for specifying the file from which you will import the records and for setting up the field mapping needed to import the data. Both of these settings will be retained as part of the script step.

          • 2. Re: Import script steps
            JCPython

            well there are several tables in the .USR file to import records from, i can set the fields to be imported, however when im thinking i need to add the import script step to set the specifics for each seperate table because when i switch from the table to table in the specify diolog, the fields matching reset on me.

            • 3. Re: Import script steps
              philmodjunk

              Yes, you will need a separate import records script step for each table. You may also need to update the next serial value settings for any auto-entered serial number fields.

              • 4. Re: Import script steps
                JCPython

                oh ok, so i would just create the script steps for all the tables and then the matching field settings will remain saved? also could you explain more on what you mean about the serial settings? i dont follow.

                • 5. Re: Import script steps
                  philmodjunk

                  Each Import Script step should retain the field mapping you specify.

                  With regards to serial number fields:

                  Say you have an auto-entered serial number that is set to enter 200 when the next new record is created in that table. The copy you are replacing may have this same serial number field, but with 2223 as the next serial value. If you import this data from your original file into the new version, the next new record will be numbered 200 and this will match that of one of the imported records--which can really scramble your data if this field is used as the primary key that matches to related records in another table.

                  Thus, either manually or via script, you should also update each such field to a value that is greater than the largest serial number value in the records imported to avoid such conflicts.

                  • 6. Re: Import script steps
                    JCPython

                    would this serial reset be needed if the import was only suppose to be done on a clean database, meaning no previous records in it?

                    • 7. Re: Import script steps
                      philmodjunk

                      Yes. the issue is with the data you are importing, not the data already present in the database. You'll have to look at the design of your new file and see what serial number fields are used in relationships to make sure each is updated as part of your import script.

                      • 8. Re: Import script steps
                        JCPython

                        Im running into a problem,

                         

                        i created a script with,

                        Import Records [no diolog;"filetoimport.USR";Add;Windows ANSI]

                        i went to manage database in the newer database and changed the next serial value for breedingID auto serial field in the breeding table, and imported the records from breeding table of the old database. The records show up fine in the auto created layout for that table, but i only have these records seen on the Reptiles table via relationship, wondering if this is a incompatibility when importing records that it wont show up the relationships?

                         

                        Relationship is set up like, Reptiles::ReptileID ---- =  ---- Breeding::ReptileID (Allow creation of records in this table via relationship)

                        Both ReptileID fields are indexed, Auto-Serial (incresement =1)

                         

                        But before i did import i set the next serial number in Reptiles::ReptileID to 83, since 82 is the highest record in the BreedingID in the old database to be imported...

                        • 9. Re: Import script steps
                          philmodjunk

                          The next serial value setting only affects the number assigned to the next new record.

                          This statement indicates a basic design issue with your database:

                          Both ReptileID fields are indexed, Auto-Serial (incresement =1)

                          Only one of the two fields should be defined as an auto-entered serial number. The other should be a plain number field. In a relationship, the parent record gets an auto-entered serial number and the related child record gets a copy of this same value to link it to the parent.

                          Did you by any chance enable auto-enter options when importing the data into one or both of these tables? That option should not be enabled for this type of import. Enabling it causes fileMaker to apply all auto-enter field options during import and this will give all imported records brand new serial number values--which could easily break the link between tables of related records.

                          • 10. Re: Import script steps
                            JCPython
                             Thanks, that makes sence, ill change all my child ReptileID to plain text box,. Im sure i did check auto enter, ill give it another try with these changes and see how it works
                            • 11. Re: Import script steps
                              JCPython

                              i was wrong about both ReptileId being auto serial, i actually had them setup correctly, i did however have the auto eneter checkbox checked on the import specifics, so i unchecked that and reran the script, but unfornetly i get the same results, the records show up in the the Breeding Default Layout, but not in the main screen on the portal that relates to the breeding table.

                              • 12. Re: Import script steps
                                philmodjunk

                                You'll need to check the relationship in the new file. Check what's set up in Manage | database | relationship, what's set up on your layout and then compare the values of the key fields for the records that should match in a relationship and don't. You may want to copy reptiles::ReptileID to the clipboard, switch to a layout based on Breeding and perform a find for that value by pasting it into the Breeding::ReptileID field to see if any such record is found.

                                • 13. Re: Import script steps
                                  JCPython

                                  unfortunetly the .usr file is of a database developed by someone else who is unable to contact. i cant view the manage database on the that file, only on the newer file which is mine can i access. i guess all i can do is play around with it and try different things.

                                  • 14. Re: Import script steps
                                    philmodjunk

                                    I'm suggesting that you check this in your file to see why the imported data does not match up.

                                    1 2 Previous Next