Newbie: Filemaker find record

Folks,

I’m new to using AppleScript. I’m wanting to find a way to have a script ask Filemaker (6.0 on OS X) perform a find for a specific record against a specific field. I’m trying to do this:

set irisSourceName to “Spiro”

(* Specify the web location of the Spiro collection images so that it can be stored in IRIS *)
set spiroLowResImageDirectory to “http://localhost/~jlk4p/Sites/spiro/preview
set spiroMediumResImageDirectory to “http://localhost/~jlk4p/Sites/spiro/preview
set spiroHighResImageDirectory to “http://localhost/~jlk4p/Sites/spiro/preview
set spiroMasterImageDirectory to “http://localhost/~jlk4p/Sites/spiro/preview

tell application “FileMaker Pro”
– Make sure the source file is open so we can identify the Spiro source information.
open “Macintosh HD:Users:jlk4p:data:IRIS:Source.fp5” with password “master”
set irisSourceDB to a reference to database “Source.fp5”
if (exists irisSourceDB) is false then return
– Get the record information for the source item.
set sourceSearchRequest to create new request in irisSourceDB
set Collection to irisSourceName in sourceSearchRequest
find sourceSearchRequest
– Make sure the spiro slide collection is open so we can process each of the image records.
open “Macintosh HD:Users:jlk4p:Sites:spiro:spiro_slide_view.fp5”
set spiroSlideViewDB to a reference to database “spiro_slide_view.fp5”
if (exists spiroSlideViewDB) is false then return
set spiroSlideViewRecordCount to the count of records of spiroSlideViewDB
end tell

But I get an error about coercing the data type. I’m probably way off since I’m just looking at questions on this forum to learn what I can. Anyone with an idea?

Thanks,
Jack

Um, I don’t understand what you are trying to do but if you are trying to open a database, search for every record where the value of cell x is y and then do something with that record then this code works for me and might get you started:

Jon

Jon,

Thanks for the code snippet. That’s exactly what I’m looking for. In my case the search should return only one record.

show the_rec

generates a FileMaker Pro object not found error. I did add a dialog to display the number of records, thinking that the search was not finding a matching record. However, I am getting one record as the result of the search. Then I commented out the line since I don’t care to view the record I just want the data from it. But I get the same error on

set the_values to every cell of the_rec

Is ID in the line

set the_rec to (ID of every record of the_db_ref whose cellValue of cell search_field = search_string) as list

a reserved word representing the primary key for the table?

I really appreciate the help,
Jack

For anyone looking at this thread and wanting a working solution. Jon’s code did not work as is. I had to modify one line to get it working correctly:

set the_rec to (a reference to record ID (item i of found_recs as integer) of the_db_ref)

The reference should be to record ID not record, since record IDs are being saved from the search request.

On my machine (FMP 5.5/Mac OS X 10.3) changing this line had no effect–they both worked and returned the same results.

Jon