Jump to content

AppleScripts don't work after migration to 7.0


This topic is 6968 days old. Please don't post here. Open a new topic instead.

Recommended Posts

  • 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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

This topic is 6968 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

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