FileMaker To OS X Address Book
The AppleScript code below can also be found in the Contacts.fp5 file that is one of the 2 files that make up a simple example of how to use AppleScript to move data to the OS X Address Book.
You can download both files here.
tell application "FileMaker Developer"
tell database "Contacts.fp5"
-- go to layout "Other"
-- do script "Go to Local Other"
set first_name to cell "FirstName" of current record
set middle_name to cell "MiddleName" of current record
set last_name to cell "LastName" of current record
set org to cell "OrganizationName_LU" of current record
set dept to cell "Department" of current record
set name_suffix to cell "suffix" of current record
set mr_mrs to cell "Prefix" of current record
set notes to cell "Notes" of current record
set home_URL to cell "URL" of current record
set job_title to cell "Title" of current record
--set birth_date to cell "Notes" of current record
set the_phone_numbers to get data cell "PhoneNum#ID::Number" of current record of database "Contacts.fp5"
set the_phone_labels to get data cell "PhoneNum#ID::Type" of current record of database "Contacts.fp5"
set AddressHome_CT to get data cell "AddressHome_CT" of current record of database "Contacts.fp5"
set AddressWork_CT to get data cell "AddressWork_CT" of current record of database "Contacts.fp5"
set AddressOther_CT to get data cell "AddressOther_CT" of current record of database "Contacts.fp5"
end tell end tell
tell application "Address Book"
--activate
set newPerson to make new person with properties {first name:first_name, middle name:middle_name, last name:last_name, organization:org, department:dept, suffix:name_suffix, title:mr_mrs, note:notes, home page:home_URL, job title:job_title}
set the_count to count of the_phone_numbers
repeat with i from 1 to the_count
-- a_phone_number in the_phone_numbers
tell newPerson to make new phone at end of phones with properties {value:(item i of the_phone_numbers), label:(item i of the_phone_labels)}
end repeat
if AddressHome_CT ≠ "" then
tell newPerson to make new address at end of addresses with properties {street:AddressHome_CT, label:"Home"}
end if
if AddressWork_CT ≠ "" then
tell newPerson to make new address at end of addresses with properties {street:AddressWork_CT, label:"Work"}
end if
if AddressOther_CT ≠ "" then
tell newPerson to make new address at end of addresses with properties {street:AddressOther_CT, label:"Other"}
end if
save addressbook
set AddressBookID to id of newPerson
-- return result end tell
delay 1
tell application "FileMaker Developer"
-- activate
set cell "AddressBookID" of current record to AddressBookID end tell
|