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.

Applescript an import of a reference

Featured Replies

I know, I know, I should bite the bullet and buy the TROI plugin. But I don't WANT to buy a plugin! I know it was mentioned elsewhere in the forum, that it is possible to set a container field to a picture, but to store it as a reference, in applescript. How?

The Applescript code is basically:


set picFile to reference to file "Macintosh HD:MyFolder:MyFile.jpg"

set cell "picture" of current record to reference to picFile


Here is a simple script to import references to all jpg's from a folder into individual records of a Filemaker file:


tell app "finder"

-- change the following to suit your own folder name

set myfolder to "Macintosh HD:photos:jan2002"

set mypics to ( name of every item in folder myfolder) as list

end tell

-- change the following line to suit your database name

tell database "PicCatalog.fp5" of app "Filemaker Pro"

repeat with i from 1 to count of mypics

set filename to (myfolder &":"&(item i of mypics))

-- skip files that are the wrong type

-- change the following line to suit your image file type

if filename ends with ".jpg"

set picFile to reference to file filename

create new record

-- picture is the container field where the import goes

set cell "picture" of last record to reference to picFile

-- picref is a text field that holds the path/file name

set cell "picref" of last record to filename

end if

end repeat

end tell


If you already have graphics in your database and want to find the pathname that's stored you can do this:


-- Finding the filepath name of a picture in the current record only

-- If you want to do all records, place this in a Scriptmaker loop

tell database "PicCatalog.fp5" of app "Filemaker Pro"

-- "picture" is the name of the container field

set pathref to cell "picture" of current record

-- picref is a text field where the file name and path will be deposited

set cell "picref" of current record to pathref as text

end tell


Because of black magic involved in Applescript parsing, it won't work if you combine the two set commands from the above script into the following single line:

set cell "picref" of current record to (cell "picture" of current record) as text

I discovered this after a couple of hours of hair-pulling. Grrrr!

  • Author

Thanks, worked like a charm! I knew it had to be something like that! Thanks again

  • Author

Ok, well, I made the script I was making, it worked perfectly. Now, I'm making a nearly identical script that imports eps's in a loop, names match the primary key of the files I'm importing them into. The eps's are good, I can import them manually, but when I run the script I get an error: -43. Have you experienced this?

Error -43 is "File not found," which generally means that you somehow specified the wrong file name or wrong path. Try putting a display dialog step in your script to see what file name and path applescript is getting. Like this:

display dialog myFilename & " " & myFilePath

Create an account or sign in to comment

Important Information

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

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.