Re: Address Book scripting
Re: Address Book scripting
- Subject: Re: Address Book scripting
- From: Paul Berkowitz <email@hidden>
- Date: Sun, 12 Sep 2004 10:34:57 -0700
Title: Re: Address Book scripting
On 9/12/04 7:09 AM, "John" <email@hidden> wrote:
I'm trying to select an entry in Address Book from a FMP script. Any ideas?
John
(* get name from FMP *)
tell application "FileMaker Developer"
set lookupName1 to field "First Name" of table "Contacts"
set lookupName2 to field "Last Name" of table "Contacts"
set lookupName to field "Contact Name" of table "Contacts"
end tell
(* look the name up in Address Book,
if the name doesn't exist, create a new record *)
tell application "Address Book"
activate
if not (exists person lookupName) then
make new person at the end with properties {first name:lookupName1, last name:lookupName2}
save addressbook
end if
person lookupName (* this doesn't work *)
end tell
To use that syntax:
person lookupName
you must use the format of the name as it appears in the "All" column in the Jaguar Address Book. If the user, for example, has LastName FirstName word order, then the format will be "LastName FirstName" with a space between if both names exist, or just one name, no spaces, if only one name exists. If the person has a middle name, that's included too. If the person has a Prefix (title), e.g. "Dr.", that's included too, plus a space. If the person has a suffix - e.g. "Jr." - that's included too, preceded by a space. Combining all this with middle names is quite "interesting", by the way. (Try it.) If there's neither first nor last name but there's a nickname, that will be shown. If there's neither first nor last name but there is a company ('organization') OR the 'company' box is checked, then the name will just be the company. If there's no company either, but there is an email address, that will be shown as 'name'. And if there's no email address either, but there is an iChat 'AIM handle', then that's shown. Only in the case of BOTH first and last names do the prefix and/or suffix display - not otherwise.
All this takes a lot of scripting. If you have formed the "lookupName" in "Contact Name" field in FMP on some other principles than that which Address Book uses, it won't work. You need to form it the same way in FMP, or, better, reconstruct it in your script when looking for the name. Furthermore, **FirstName LastName name order of Address Book prefs is NOT scriptable**. It's not discoverable by script - you have to depend on your user to have the prefs consistent with a script pref you can include.
It might be safer, though definitely slower, just to do it this way:
set thePerson to first person whose last name is lookupName2 and first name is lookupName1
Even then, you'll have to be ware that if you set a first (or last) name to "" by script it's uneditable in the UI. It's better just not to set it, and then look for 'missing value' of properties of thePerson.
I've used the complicated method myself. It does create problems when the user ignores my warnings about setting script prefs to the same as Address Book's name order prefs.
--
Paul Berkowitz
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden