I have a FileMaker database with fields for first name, last name, email address, and many others. I want to get that information into the Contacts app. For years I did it with an AppleScript, which is called from a native FileMaker script, which is attached to a button in the database, and it took maybe one second to run. Since moving to more recent macOS versions the script takes forever. The odd thing is, the script is still super-fast when run from Script Debugger.
Here is the script.
use AppleScript version â2.4â â Yosemite (10.10) or later
use scripting additions
global firstname, lastname, emailaddress, yearofgraduation
tell application "FileMaker Pro"
tell database "College Circuitry all info"
tell current record
set firstname to cellValue of cell "Student First Name"
set lastname to cellValue of cell "Student Last Name"
set emailaddress to cellValue of cell "Student e-mail"
set yearofgraduation to cellValue of cell "Year Of Graduation"
end tell
end tell
end tell
--
tell application "Contacts"
activate
-- VERY FAST TO HERE
--
-- STUDENT PART --
set thegroups to name of every group as list
set thegroupname to yearofgraduation & " students"
--
if thegroupname is not in thegroups then
make new group with properties {name:thegroupname}
end if
--
set x to make new person with properties {first name:firstname, last name:lastname}
save
tell x
make new email at end of emails with properties {value:emailaddress}
end tell
set groupname to group thegroupname
add x to groupname
save
--
display dialog firstname & " " & lastname & " has been added to the Contacts app."
end tell
Iâve tried to find where the slowdown is and I know for sure where it ISNâT:
It isnât slow getting the info from FileMaker. if I do a âdisplay dialogâ with the info Iâm grabbing, and a Return statement, it happens in a fraction of a second.
It isnât slow launching Contacts.
Where is seems to be slow is actually doing the work in Contacts. There isnât much to it (make new contact with properties, and then a save) but it takes minutes. Basically unusable.
I am guessing that this has something to do with newer security features in newer macOS versions. I think this problem began with 10.11 but it could have been 10.10.
If I run the script from the AppleScript script menu everything is fast, same as if I run it from Script Debugger. But itâs not as good as having the clickable button on the FileMaker database.
Iâve seen some other mentions of this sort of thing (FileMaker being slow to execute AppleScripts in new-ish macOS versions) but no solution. Anyone have an idea for me?