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.

Exporting container fields

Featured Replies

  • Newbies

I am trying to write a script that incorporates a calculated Applescript to allow a user to select or create a folder, and then export the contents of a container field for all records in the selected set.

The AppleScript gets the path, and sets a field to its value. Such as: "/Users/username/Desktop/Pictures/"

For those who care, the AppleScript looks like this (it is in a calculated field so that I can retrieve the current database name--"MyDatabase" is an example of the calculated name):

set selected_path to choose folder with prompt "Please select a destination folder:"

set selected_path_posix to POSIX path of selected_path

set selected_folder to selected_path_posix as text

try

tell application "Filemaker Pro Advanced"

tell database "My Database"

set contents of field "Image Export Folder" to selected_folder

end tell

end tell

end try

I am not an AppleScript programmer, so this may be ugly, but it works!

Then I run a loop that

1) sets a variable $filePath to the path that was put in the field by the AppleScript, and appends the current field contents name, which results in (for example): $filePath = "file:/Users/username/Desktop/Pictures/image1.tiff"

2) Performs an Export Field Contents for the target field to the Specified Output File based on the path and name for the $filePath variable

There is some problem with the Specify output file path that is causing an error. I get a dialog that says the file cannot be created. It reads:

“image1.tiff” could not be created on this disk. Use a different name, make more room on the disk, unlock it or use a different disk.

What am I doing wrong in specifying the filepath? I've tried appending the word "file:" to the head (as above), leaving it out, and even adding the system "Filemac:/Users....etc."

If I uncheck Specify filepath, it or course works fine, but I need to automate the save since I am exporting hundreds of images.

It only needs to work in a Mac environment, so I am not too concerned with detecting Windows at this point...

Any ideas out there!?

$filePath = "file:/Users/username/Desktop/Pictures/image1.tiff"

An absolute path to a folder should look like:

filemac:/volumeName/folder/folder

In your example it would probably be:

filemac:/Macintosh HD/Users/username/Desktop/Pictures/image1.tiff

See:

http://www.filemaker.com/11help/html/create_db.8.32.html#1030283

  • Author
  • Newbies

An absolute path to a folder should look like:

filemac:/volumeName/folder/folder

In your example it would probably be:

filemac:/Macintosh HD/Users/username/Desktop/Pictures/image1.tiff

See:

http://www.filemaker.com/11help/html/create_db.8.32.html#1030283

Hmmm....I tweaked my script to generate the absolute path properly, and got the same error. Here is the path my script is generating:

filemac:/Macintosh HD/Users/username/Desktop/test_export/image.jpg

Here is the formula that sets the variable $filepath:

=========================================

Let (

prfx = Case ( Abs ( Get (SystemPlatform)) = 1; "filemac:"; "filewin:");

prfx & Replace(Get(SystemDrive);Length (Get(SystemDrive));1;"") & Shot Breakdown::Image Export Folder & Shot Breakdown::Shot Image Info

)

=========================================

FYI - I delete the slash at the end of the detected SystemDrive with the Replace function because it gets doubled with the "Image Export Folder" path field, but it all seems to work to generate a proper absolute path as per your note.

This is very frustrating!

  • Author
  • Newbies

Hmmm....I tweaked my script to generate the absolute path properly, and got the same error. Here is the path my script is generating:

filemac:/Macintosh HD/Users/username/Desktop/test_export/image.jpg

Here is the formula that sets the variable $filepath:

=========================================

Let (

prfx = Case ( Abs ( Get (SystemPlatform)) = 1; "filemac:"; "filewin:");

prfx & Replace(Get(SystemDrive);Length (Get(SystemDrive));1;"") & Shot Breakdown::Image Export Folder & Shot Breakdown::Shot Image Info

)

=========================================

FYI - I delete the slash at the end of the detected SystemDrive with the Replace function because it gets doubled with the "Image Export Folder" path field, but it all seems to work to generate a proper absolute path as per your note.

This is very frustrating!

Figured it out!! In the found set some of the fields were empty, and therefore the script was unable to write the image so it generated an error. A simple IF test solved it:

If [shot Breakdown::Shot Image Info ≠ ""]

Export Field Contents (etc.)

End If

Works like a charm!

The functionality to let a user select and create a destination folder from within Filemaker seems like something that should be built in! It was fun figuring it out though--thanks for your help!

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.