apple script within filemaker pro 11

Hi all,

I’m trying (without much luck) to import pdf’ links into a column of records (containers) in fmp-11. I’m using an apple script to do this but it’s not working. I get an error 10006 (-10006/The read operation wasn’t allowed/Apple Event Registry). I have two fields one called “global” in which I put the path to the pdf folder and the other called “MSDS” where the pdf links should go.

The “MSDS” skript looks like this:

set imports_folder to choose folder

tell application "Finder"
	set aList to (every file of imports_folder whose name extension is "pdf") as alias list
	my list_to_text(aList)
end tell

set list_txt to my list_to_text(aList)

-- set global field to file paths as text list
--tell application "FileMaker Pro Advanced"
	activate
	set cell "z_gFilePaths" of table "Globals" to list_txt
	save record
--end tell

on list_to_text(aList)
	set {tdl, AppleScript's text item delimiters} to {AppleScript's text item delimiters, return}
	set newList to aList as text
	set text item delimiters to tdl
	return newList
end list_to_text

I received this template from a member (Fenton Jones) who kindly helped me import csv files. The script worked beautifully for that and I thought I could convert it for the pdf stuff but something is obviously wrong.

Any help would be appreciated.

Thanks,
Bob

Model: power PC G5
AppleScript: 2.2.1
Browser: Firefox 3.6.3
Operating System: Mac OS X (10.5)

It’s me again :-] The main part of the script works fine. So, one suspects the FileMaker setting of the field is the cause of the error. Because it is:

  1. a global field, and
  2. the table was specified

That narrows down possible errors to:

  1. Field is wrong name
  2. Table is wrong name
  3. There are no records in the (1 record only) Globals table (AppleScript requires at least 1, tho FileMaker doesn’t).

There is often confusion (at first) about what a “table” is, when accessing FileMaker from an external application. It is NOT the base tables which you define in the Tables tab. It is the Table Occurrences on the Relationship Graph. The FileMaker API for AppleScript (and anything else I believe) only sees the graph, it does not see the base tables.

Unfortunately the word “table” is often used when really it should be “table occurrence”, both in the documentation, and in AppleScript. So just know, it’s the names on the graph that matter.

hey Fenton,

Good to hear from you again.

Thanks for the info. I’ll check all this and get back to you.

I’m glad there are geeks like you around for the rest of us :slight_smile:

Bob

Hi Fenton,

You where right. The table “MSDS” was not in the relationship area. So after fixing that I ran the script. But instead of dumping the PDf’s in the “MSDS” table it put everything (including pathway search) in the global container. In other words the container had a pathway list ending with the pdf file name for each pdf file.

table “globals” is set to type=text Options=Global

Thanks for any suggestions and have a good weekend.

Bob

If it put the file paths into the container field then the mostly likely problem is that you targeted the wrong field. Container fields can accept text; but it makes no sense to do so.