4 Replies Latest reply on Mar 26, 2010 7:40 AM by elizas

    Import script

    RGoyette

      Title

      Import script

      Post

      I am writing a script to import data into a database and I want to give the user the choice:  import from an ODBC data source or from a local file.  I use a custom dialog box to capture the user's choice.  The OBDC part is done and works well.  The trouble is the local file part.  The file can be called anything and located anywhere.  How do I manage to allow the user to specify the file name and location so that I can store it in a variable that can be passed to Import Records?  In addition, the file from which I am importing has several layouts each of which has a list of records that need to be imported.  How do I specify which layout to use when importing?

        • 1. Re: Import script
          TSGal

          rjgoyette:

           

          Thank you for your post.

           

          You may want to create a couple of global fields.  This way, the user can enter the filename into one field, and the path into a second field.  Then, store both into a variable and use that as part of the Import Records script step.  For example:

           

          Set Variable [ $file ; If ( Abs ( Get ( SystemPlatform) ) = 1 ; "filemac:" ; "filewin:" ) & <global field for path> & <global field for filename> ]

          Import Records [ no dialog ; $file ; <specify field order> ]

          Go to Layout [ <layout you want to show after importing> ]

           

          You can also specify a layout by a calculation.

           

          Let me know if you need clarification for any of the above steps.

           

          TSGal

          FileMaker, Inc. 

          • 2. Re: Import script
            HugoLidia
               Is there not a way to let the User browse to their directory/file to select it, as in Explorer?  Then capture that path and selected file name.  That's what would be available in any other programming software, or do we have to add this to a FMP wish list?
            • 3. Re: Import script
              philmodjunk
                 You can set up a script that pops up the open file dialog for the user to select a file from which to import. Just clear the data source option and don't select the perform without dialog option.
              • 4. Re: Import script
                elizas

                In File Maker, copying and pasting scripts are not quite easy as scripts never behave like texts, that can be copied and pasted in Filemaker script editor. If there are some modifications in some of the scripts in a file, then it is not needed to copy and replace the whole file in the client's live application, Modification should be done for that particular script. It happens that if some logic or new functionality is required to be implemented, then there is a need to create the scripts at the developer's end and QAing will done for that new modification, then that script again needs to be written in the Client's live application. Because of live data, the script written in the client's end can not be checked. As the script is written directly and not tested then that script may have some defects. Those defects will appear at the time of work for that functionality in live, which is a big problem. To prevent this kind of situation, "Import Script" option can be used.

                 

                Eliza