Skip to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Use of variables as a file name for record import?

Featured Replies

I am trying to build a script, that would allow the user to import multiple records at once.

I have a field, where the user enters the file names, that should be imported. All files have the same format, the same import order and would be in the same folder. My problem is, that FM ScriptMaker does not allow me to put a field of the database in the import records function to specify the data source. Is there a way to do that?

Any help highly appreciated.

Joern

FileMaker Version: Dev 7

Platform: Mac OS X Panther

  • 3 weeks later...

I consider it a lousy work-around, but this is what I have done. It only works for the case where you can pre-define a list of available files. I have not been able to figure a way to have users add files to the list.

Create file references for each file.

Create a text field with the name of the file reference.

In a script use:

If [ textfield = "filename' ]

Open File [ "filename" ]

Spelling has to be exact, so consider limiting the text field to a pop-up list.

Another way is to use either AppleScript or a plug-in, such as Troi File plug-in, to list the files in the folder, then, in a loop, rename each to a fixed name, import it, then rename it back to the original name.

Both tools above have a "list folder" command, producing a return-delimited list of the file names, which you can put in a global field. Then, using FileMaker, you can loop through and process one file at a time.

You do have to know where the folder is, but this can be calculated relative to the database file, using Status(CurrentFilePath), or Get ( FilePath) in 7, minus Status(CurrentFileName), plus the relative path to the folder & fixed file name.

There are various ways to calculate the current folder path. Here's my Mac one for v.6:

Substitute(Substitute(Left(Status(CurrentFilePath), Position(Status(CurrentFilePath), "/", 1, PatternCount(Status(CurrentFilePath), "/"))), "/", ":"),

"file:???:", "")

Similar for 7, one less ":" in "file::"

Substitute(Substitute(Left(Get(FilePath); Position(Get(FilePath); "/"; 1; PatternCount(Get(FilePath); "/"))); "/"; ":");

"file::"; "")

The advantage of this name switching method is that you don't need to know the names of the files in the folder, or how many there are. Both AppleScript and Troi File can easily rename a file very fast.

A variation on Fenton's technique is to do nothing to the original files. Create a single import script that imports a file from a fixed location and fixed file name; maybe importme.txt.

The loop that Fenton describes is modified to one at a time, create an alias to each of your source files, name the alias importme.txt and put the alias in the known location, and perform the import, then repeat.

Create an account or sign in to comment

Important Information

By using this site, you agree to our Terms of Use.

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.