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.
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:
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.
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
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?
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's got it. Let me make my suggestion a little more detailed.
<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 … ]
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.
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?
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
11th Hour Group Pty Ltd
Retrieving data ...