6 Replies Latest reply on Sep 19, 2012 2:48 AM by LyndsayHowarth

    importing from another table in the same file

    garyavischious

      I want to import records from one table to another, in the same file. It's a template file, so I don't want to have to re-do all the scripts that reference the name of the file in import scripts, if I make copies of the file.

       

      Any suggestions?

        • 1. Re: importing from another table in the same file
          robwoof

          In the import script, use Get (FileName) to put the file's name into a variable, say "$fileName". The "source" file you import can then be referenced as:

           

          file:$fileName

           

          Since no path is specified, you're saying "use the file whose name is in $fileName and whose location is the same as this file". So you get same file name, same location, and a bulletproof script. It works whether the file is open single-user or shared on FileMaker Server or peer-to-peer.

          • 2. Re: importing from another table in the same file
            garyavischious

            I seem to be missing something in the execution of this.

             

            I named a calc field called: FileName

            and defined the calc as equal to Get(FileName)

            it displays correctly

             

            In the import script I have entered it as

            file:FileName

            and it comes up as saying the file is missing.

             

            Is the $ you note part of the syntax or part of the naming.  If part of the naming it gives me an error saying I can't name with that.

             

            Can you clarify this for me?

            • 3. Re: importing from another table in the same file
              Malcolm

              Is the $ you note part of the syntax or part of the naming.  If part of the naming it gives me an error saying I can't name with that.

               

               

              Can you clarify this for me?

               

              Look for the script step called "Set Variable". It's near the top. I like to think that the FMI programmers put the script steps in order, sorted by the number of times you are likely to use them.

               

              Also, read the help section on Variables.

               

              Malcolm

              • 4. Re: importing from another table in the same file
                robwoof

                Malcolm's got it. Let me make my suggestion a little more detailed.

                 

                <Script>

                 

                <set up the found set you want to import into the other table here>

                Set Variable [ $fileName ; Get (FileName) ]

                Go To Layout [ <whichever layout you need for the table you want to import into> ]

                Import Records [ No dialog; $filename … ]

                 

                </Script>

                 

                Note: when you add the Import Records script, you will need to specify the file explicitly in order to select the table you are importing from and map the fields. Once you have done that, you can remove the explicit reference and just leave "file:$fileName" in the "Specify File…" dialog.

                 

                HTH

                Rob

                • 5. Re: importing from another table in the same file

                  Maybe I'm missing something but wouldn't it be simpler to rename the files using Developer Utilities so the import scripts just change their reference?

                  • 6. Re: importing from another table in the same file
                    LyndsayHowarth

                    but that doesn't deal with the issue of "same file". I imagine this is because the found set in one table needs to populate another table in the same file.

                     

                    Sent from my iPad

                    Lyndsay Howarth

                    11th Hour Group Pty Ltd