Jump 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.

AppleScripts don't work after migration to 7.0

Featured Replies

  • Newbies

Hi All

I had (what I thought was) a perfectly simple AppleScript to place pictures into container fields based on a field that containing a filename. Unfortunately it no longer works in FM7.

Also, I had another series of simple scripts to open the placed pictures into Preview that no longer work.

I would appreciate it greatly if anyone has the time/interest to check out my scripts and offer any advice they may have. Hopefully its a syntactic problem. Below are copies of the scripts.

Thanks

Brad

To import pictures into the current record:[color:"blue"]

set folderPath to (choose folder with prompt "Import Photos from...")

tell application "FileMaker Pro"

activate

try

tell application "FileMaker Pro"

set PathA to folderPath & (cell "FilenameA") of current record as string

set cell "PictureA" of current record to file (PathA)

set cell "PathA" of current record to (PathA as text)

[repeats for several sets of fields...]

end tell

end try

end tell

To open the original file into Preview:[color:"blue"]

tell application "FileMaker Pro"

set PictureRef to cell ("PathA") of current record as string

end tell

try

tell application "Preview"

activate

open file PictureRef as alias

end tell

on error

tell application "FileMaker Pro"

activate

end tell

end try

Just a wild guess, I think you need to specify which table within the file you're working with. Since FM7 now allows multiple tables in a single file, simply specifying the file and the field is not enough. I've not used FM7 Applescript yet, but I suspect you'll need a "tell table foo" in there somewhere.

Here's a previous thread you might find helpful.

http://www.fmforums.com/threads/showflat.php/Cat/0/Number/102070/Main/101951

One little "gotcha." In AppleScript the term "table" means, in FileMaker, table occurrence. It's not the name of FileMaker defined table, it's the table occurrence on the Relationship Graph assigned to the desired layout.

Another way to avoid this is to make sure you're on a layout in FileMaker which belongs to the TO you want, and which has the fields on it.

Then you can use "window 1" and "current record". That's the simplest.

A "document 1" reference no longer means the current document; it means the 1st document opened that session (I think, not sure, I don't use it anymore). You can also specify the document and window by name.

One advantage of going to the right layout in FileMaker, then using a generic window 1 reference is that no names are "hard-coded" into the AppleScript, so it won't break if you edit the table occurrence name, or the window name (possible in 7).

You don't say whether this is in a Perform AppleScript step or not. If so, you don't need to "tell FileMaker Pro", as it is running the script and knows who it is (unless this is inside another app's tell block).

Also, your script is choosing a folder, then using a field in FileMaker to get the file name, then putting it together for a file path, then getting the file's image as a reference, then setting a field in FileMaker to the file path. But it's only processing 1 file. I'm curious as to why.

Removing extraneous FileMaker calls, if in a Perform AppleScript step:

set folderPath to (choose folder with prompt "Import Photos from...")

tell window 1

try

set PathA to folderPath & (cell "FilenameA") of current record as string

set cell "PictureA" of current record to file (PathA)

set cell "PathA" of current record to PathA

[repeats for several sets of fields...]

end try

end tell

Create an account or sign in to comment

Important Information

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

Account

Navigation

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.