3 Replies Latest reply on Dec 3, 2012 2:43 PM by philmodjunk

    Scripting imports



      Scripting imports


           Can someone assist me in writing a script to automate importing?

           I have a contacts database.  Some of these contacts are physicians.  In an electronic medical records system, these physicians appear, as well as the patients under their care.  I can export an excel file containing each physician and the first and last name of each patient under their care.  In my contacts database, I have a portal in each contact's record that lists the patients under their care....however this portal is empty until I import the data.  I want to create a button with a script attached that basically contains all of the settings for the import.  Clerical users would ONLY have to export the excel file from the electronic medical records to their desktop/a folder and then click the button on my contacts layout, which will only prompt the user to select a file to import.  All settings and match fields will be taken care of via the script without user interaction.  Is this possible?


        • 1. Re: Scripting imports

               It is possible. How much experience/ability do you have for writing scripts?

               Here's a general outline of a method that I use.

               Define a global container field and put it on a layout.

               Write your script to:

               1) change to layout with container field.
               2) Use Insert File to insert the file to be imported into the container field with the "store a reference" option specified. Do not click the "no dialog" option, instead, a dialog box will appear where the user can select the excel file for import.
               3) Extract the file path to this file from the container field, putting that path into a variable.
               4) Use the variable with Import Records to import the data from the file that the user selected in step 2.

          • 2. Re: Scripting imports
             I understand scripts and have been improving in my abilities.  I think I get it, just not sure how to define the match field(s) and automate the data to be imported.
            • 3. Re: Scripting imports

                   The trick to setting up matching fields is to set up the script step with a data source reference to two files:

                   A reference to an Actual excel sample file formatted the way you need for these imports.

                   $Path will receive a value from a set variable step that extracts the file path from the container field. The second line is a direct reference to a file you have on your hard drive at the time you create this script step. The presence of this file reference lets you set up the matching fields and other import records settings for your script step and they will be retained and, as long as you have that file in place, you can return to this script step any time you need to modify the import records options. But when you run the script, the script step will use the file path in $Path to find and import your data.

                   When testing your script, it's a good idea to move or rename your sample excel file first, to make sure that your script is successfully importing from the file selected via insert file in your script.