Filemaker error using Applescript. Commit Records?
I have an applescript that inserts alt tags in html pages using TextWrangler. The information going into the alt tags comes from a field in my Filemaker Pro 12 Advanced database. All works well most of the time. Then at random times it will get an error stating that Filemaker cannot find the record, or to be more accurate,
"error "FileMaker Pro Advanced got an error: Event not handled." number -1708 from every record of database "myDatabase" whose cell "FolderName" = "Aeroplane"
I am pretty certain this is an issue with Filemaker not allowing access from an external application. If I were running the applescript from within Filemaker then I would just include a Commit Record/Request step and all would be well. However, the only way I can do this, I think, from outside of Filemaker is to use "save current record" in the script. But that is inconsistent and therefore most probably wrong.
--lots of text manipulation then....
set theTextIWant to the second text item of theText
tell application "FileMaker Pro Advanced"
save current record
show (everyrecordofdatabase "myDatabase" whosecell "FolderName" = theTextIWant)
setmyAllTextInfotocell "Tags" ofthecurrent recordofdocument "myDatabase"
-- then go do other stuff
I make sure that I do not have the cursor in any field when I start running the script. Quitting Applescript and Filemaker and restarting both seems to fix the problem, temporarily. So I am pretty sure it's a problem with the "save current record" bit not doing what it's supposed to do.