Search code examples
applescriptfilemaker

Sending data from AppleScript to FileMaker records


I'm computing some data in AppleScript that I'd like to then insert into a specific FileMaker record. Here's my AppleScript:

on sendDataToFM(FileNameWithExtension, ClipLength)
    tell application "FileMaker Pro Advanced"

        show every record of database 1
        show (every record whose cell "File Name" = FileNameWithExtension)

        repeat with i from 1 to (count record)
            set MatchingRecord to record i
            set data cell "CLIP LENGTH" of MatchingRecord to ClipLength
        end repeat

    end tell
end sendDataToFM

...

my sendDataToFM('Some Video.mov', '00:01:22.55')

Everything works except the line

set data cell "CLIP LENGTH" of MatchingRecord to ClipLength

The error returned is

(*Can’t get cell "CLIP LENGTH" of {"Some Video.mov",  ... }.*)

The script finds the right record, and the FileMaker field name is definitely "CLIP LENGTH". What am I doing wrong?


Solution

  • Try:

    on sendDataToFM(FileNameWithExtension, ClipLength)
        tell application "FileMaker Pro"
            show (every record of current table whose cell "File Name" = FileNameWithExtension)
            repeat with i from 1 to (count record)
                set cell "CLIP LENGTH" of (record i) to ClipLength
            end repeat
        end tell
    end sendDataToFM
    
    my sendDataToFM("Some Video.mov", "00:01:22.55")