You do not need to specify layouts in order for scripted Import Records steps to work like you have to with manual uses of Import Records.
Inside the Import Records script step is an option to specify the table (actually the table occurrence) of the source file from which the records will be imported. This is what you need to select here when importing records. If the source file is closed when this step executes, you get all the records in the table, but FileMaker insists on asking you to enter the password even if a matching account name and password is defined in both tables. If the file is opened, this import will import the found set of records from the specified table occurrence. Thus it's often useful to perform a script in the source file that finds the records you want to import first, then your next step is to import the records.
Since you are using a variable to refer to the file, it's usually best to include two file references like this:
The system will refer to the literal file when you are creating the script so this makes it possible to set up field mapping and other import options. The first reference, then supercedes it when the script executes to import from the filepath inside that variable.
Thank you, Phil, I'll try that.
Is it possible that I can choose to open the source file first, then go to a specific layout, and the import records....all running form a script within my Master database? Thanks again
Why would you "go to a specific layout" for this script? I'm not clear on the reason for doing that.
You can, it's all a matter of using the script steps available to accomplish that.
Open File can be used to open the source file.
Perform script can be used to both open the source file and also to run a script in it. That's often done with such import scripts as a way to set up found sets in the source file so that they can then be imported into the target file.
I thought I needed to specify the layout in the source file first because I'm importing from mutliple tables to mutliple tables in the Master database.
I was using a variable before to let me choose a filename and path to the source data file, but without opening it, when i import the data only the data from the first layout was imported to each and everyone of the mutliple layouts in the Master.
So I thought that perhaps when I open the source data in a script I'd need to go to a certain layout in both the source and the Master, then import records
When you set up import records, you specify a table occurrence, defined in the source file, not a layout. this is part of the import records step. In that dialog this is called the "source table" but if you compare the list of names in this drop down to the table occurrence boxes found in Manage | database | Relationships in this file, you'll find that every "box" has its name listed in this drop down even if several of these occurrences refer to the same table. Each occurrence has its own found set and sort order so the occurrence you select here can affect what records are imported. If you import from a closed file, you should get all the records in the table. If the file is first opened, you get the found set of the occurrence specified, this is where a script is often performed in the source table to set up the needed found sets prior to import. This script will need to select a layout that uses the refers to the same table occurrence in layout setup | Show records from that you selected in the source table drop down.
If "table occurrence" is a new idea, you may want to check out this tutorial on the concept as this is key to understanding how Filemaker systems work: Tutorial: What are Table Occurrences?
Phil, thank you again for your in-depth explanations