Here is a script snippet that works with a Filemaker 6 database. But when I convert the database to Filemaker 7 the same script returns “AppleScript Error. Filemaker Pro got an error:object not found”. The correct database activates and only 1 found record exists in the active window.
tell application “FileMaker Pro”
activate
–INITIALIZE EVERYTHING
set dbRecord to current record of database 1 – <-THIS IS THE LINE THAT RETURNS THE ERROR AND THE WORDS “current record” ARE HIGHLIGHTED
--GET THE ADDRESS
set eMailAddress to cell "Agents eMail" of dbRecord as string
set theSubject to cell "Students Full Name"
set theSubject to "Re: " & theSubject
Don’t forget that FileMaker has now joined the mainstream. Your FileMaker 7 database doesn’t have a current record. It has tables, layouts and FileMaker scripts. I’d encourage you to follow the object model of the FileMaker dictionary. All that said, it looks all you need to do is reference your database by name not index number. My test shows that this works:
tell application "FileMaker Pro"
activate
set x to current record of database "Text_Retreive"
end tell
But this does not:
tell application "FileMaker Pro"
activate
set x to current record of database 1
end tell
Thanks guys. Both methods worked to get me past the problem stated but now the next line is broken
tell application “FileMaker Pro”
activate
–INITIALIZE EVERYTHING
set dbRecord to current record of document “Students”
--GET THE ADDRESS
set eMailAddress to cell "Agents eMail" of dbRecord -- <- NOW THIS LINE IS BROKEN
set theSubject to cell "Students Full Name"
set theSubject to "Re: " & theSubject
end tell
The data captured in dbRecord doesn’t seem to have any field names so trying to refer to cell “Agents eMail” isn’t understood. Any suggestions. I can’t get over how this works with 6 but not with 7.
Easiest solution I see is to skip the “dbrecord” statement and go straight to the “set” statements below it. something like this:
tell application “FileMaker Pro”
activate
–GET THE ADDRESS
set eMailAddress to cell “Agents eMail” of current record of document “Students”
set theSubject to cell "Students Full Name"of current record of document “Students”
set theSubject to "Re: " & theSubject
end tell
If you need the other cells you have to specify them as objects. Each one.
No shortcuts
Now if somebody here could just help me find a way to work in a hidden FMP7 window from AppleScript I would REALLY appreciate it. Nothing I’ve tried works, so far.
tell application “FileMaker Pro”
activate
–GET THE ADDRESS
set eMailAddress to cell “Agents eMail” of current record of document “Students”
set theSubject to cell "Students Full Name"of current record of document “Students”
set theSubject to "Re: " & theSubject
end tell
But I have a new problem. eMailAddress can be set to the Text field “Agents eMail”. But “theSubject” cannot be set to cell “Students Full Name”. It is a calculation field. So I have a work around which is that I created a 2nd text field and just plug the concatenated value into it and pull that simple text data into the AppleScript. But any ideas as to why a calculated field can’t be pulled into an AppleScript variable?
This should work. I just tried it and had no problem. What is happening for you? Is the calculation set to text? How about the storage options, is it unstored or a global calculation? Just throwing out thoughts? Good luck.
This goes back to my original reply on 10/30. If the calculation field doesn’t appear on the current active layout, then you must specify a layout that does contain the calculation field. When I switch to a layout that does not contain my calculation field; I must change the script to:
tell application "FileMaker Pro"
set x to cell "c_test" of current record of layout "Text_Retreive" of document "Text_Retreive"
end tell
If you had multiple tables in your database then you’ll also need to specify the exact table. Does that make sense?