Search code examples
applescriptrecordfilemaker

"current record" doesn't work: applescripting Filemaker Pro 13 in a loop


I have an Pro 13 database with around 120 records (it's for a conference). I want to team it up with BBEdit to create individual files for each abstract, thus . Much to my surprise (and despite a lot of web tips on scripting) '[tag:current record]' is not recognised in the script.

The relevant bit is this:

FM Script:
Loop
Perform Applescript

tell application "FileMaker Pro"
activate
set MyFileName to cell "WebAbstractFileName" of table "SelectionProcess"
set MyWebAbstract to cell "WebAbstract" of table "SelectionProcess" as text
end tell

-- (BBEdit bit, which works fine in testing)

 Go to Next Record (exit after last)
End Loop

This works fine if I only want to retrieve the first record!

This applescript is set within a filemaker script which loops through the records but the script doesn't care which record it's in.

I've tried adding 'of current record' before the table reference but it then gives me errors (eg error "FileMaker Pro got an error: Object not found." number -1728 from cell "WebAbstractFileName" of current record of table "SelectionProcess") Without 'current record' it works fine, but only gives me the first record.


Solution

  • Here's (roughly) how you could do this in a Filemaker script:

    Go to Layout [ “YourTable” ] 
    # FIND THE RECORDS OF INTEREST
    Perform Find [ Restore ] 
    Go to Record/Request/Page [ First ] 
    Loop 
        New Window [  ] 
        # ISOLATE THE CURRENT RECORD
        Show All Records 
        Omit Record 
        Show Omitted Only 
        Set Variable [ $path; Value:Get ( DocumentsPath ) & "someFolder/"  & YourTable::Somefield  & ".html" ] 
        Export Records [ No dialog; “$path” ] 
        Close Window [ Current Window ] 
        Go to Record/Request/Page [ Next; Exit after last ] 
    End Loop 
    

    This will export every record in the found set as an individual file into the folder "someFolder" located in the user's Documents folder, using the contents of the YourTable::Somefield field as the filename.

    If, as you say, you don't need the separate files, then of course this can be much simpler.