set up a script that uses Insert File to insert the file by reference into a container field. (it can be a global field.)
The user gets a dialog box where they select the file, but then your script can extract the file path from this container field to use with Import Records to import the data. Since this file path will contain the file extension, your script can check the file extension. You can also use the options for Insert File to limit what file extensions can even be seen in the dialog to insert in the first place.
Note: This method requires two file references inside the Import Records script step. The upper reference must be the name of your $path variable. The second reference should be a reference to a copy of the typical file from which you will import that is valid at the time you set up the script and specify your import options. This file is used to specify the column to field mapping for the import so that it will be retained in the script step.
Yes, GetValue ( ContainerField ; 2 )
will return the file path, If the following is true:
Insert File, not Insert Picture was used to insert the file.
The "Store a reference" option was specified for the insert.
For more on $Path variables, container fields and script steps that can use a $Path variable, see: Exploring the use of a $Path Variable in Scripts
Thank you Phil. It works. I didn't select "store a reference" for Insert File. that was why I did't see the calculation work.
Can you please explain a little more about "You can also use the options for Insert File to limit what file extensions can even be seen in the dialog to insert in the first place." ?
With FileMaker 12 and newer, you have a check box "Dialog Options", that opens the dialog shown in the attached screen shot. The first part of this dialog is where you can specify what file extensions are permitted to appear in the insert file dialog.
And there is also a place to specify that only "store a reference" be specified for the insert so that a user can't use the wrong insert method.
I know why I didn't get it. I am using FM 11. I am too behind. I need to upgrade.
My finding that option in Insert File was one of the more pleasant surprises when I started using FileMaker 12.