5 Replies Latest reply on Apr 25, 2014 7:58 AM by MattRoy

    Continuing a Script in a new Database File



      Continuing a Script in a new Database File



           I have a database tool that I want to send to a bunch of different email recipients with only their relevant information in it. Basically I want to break out one database file into individual files. While I can save the current database as the new file I want, I can't get my script to continue running in the new file. It just continues to run on the first file. Is there a way to have a script run on a new file? This would be like a global Excel Macro module that gets shared between workbooks.


        • 1. Re: Continuing a Script in a new Database File

               Continue running in the new file to do what exactly?

          • 2. Re: Continuing a Script in a new Database File

                 In the new database, I want to go to a few layouts and delete non relevant records, then send that file to an email recipient. The way I have it set up right now is this:

                 Script in Base Database Saves a new database for each record using Save Copy As ; "Automatically Open". This loops through the records.

                 I then have an script that triggers when the file is open (with code to only work on the new files) that deletes the non relevant data and composes the email with the file attached.

                 The problem I am running into is that when the Base File Loops, it does not "Automatically Open" the new files, and thus those files do not run their script. When I disable the loop, it works fine for one record's file.


            • 3. Re: Continuing a Script in a new Database File

                   A script can run and then pass control to another script in the same database or a second database.

                   It has been a long time since I wrote such a script.


              • 4. Re: Continuing a Script in a new Database File

                     I would do this by saving a clone (empty copy) of the file and then use scripted finds to set up found sets of records in the original copy and use Import Records in the clone copy to import those found sets into the clone to set it up for distribution.

                     Here's how I set that up in one of my systems (though not for these exact reasons):

                     I manually saved a copy of my database. I opened the copy of the database and set up a script to import records from all needed tables in the original copy--adding the needed external data source reference back to the original copy to make this work. I then closed the file, deleted the original copy and renamed the new copy to be the file name of my original copy.

                     I then saved a clone of the file (copy #3) and wrote a script in my current copy (copy #2) that used Perform Script to perform that Import Records Script in the cloned copy (copy #3). I didn't need to save new copies of my database, but this same script could first save a clone of the database, perform the needed finds, and then use perform script to import the needed records in to the clone.

                     But this only works for a single cloned copy unless you then repeat the process several times to generate the needed clones with different file names. You may find it more flexible to just open the clone files and run the script from the clone to import the data. Perform Script from the clone copy can perform a script in the main copy to set up the needed found sets. It can pass data in a script parameter to tell that scrip exactly what criteria to use in setting up each of those found sets. In this variation, you'd run a script in the main copy to generate a set of cloned copies and then you'd open and perform a script from each of the cloned copies to pull the needed data into them. (And if you get cute, you might be able to use the file name of the clone to determine the data to pass as a script parameter back to the original file in order to get found sets of the correct records.)

                • 5. Re: Continuing a Script in a new Database File

                       Thanks. I was actually able to figure it out using a hyperlink to call a script. I had a loop with the hyperlink to the copied files (with a variable) and then was able to run a script in the new database file. Works great. Thanks for the responses.