Re: Search Contacts for phone number
Re: Search Contacts for phone number
- Subject: Re: Search Contacts for phone number
- From: Axel Luttgens <email@hidden>
- Date: Sat, 27 Sep 2014 10:37:06 +0200
Le 21 sept. 2014 à 23:33, Bill Vlahos a écrit :
> How do I AppleScript a search of the Contacts application if I know the phone number? The application is a CallerID lookup so I just need to return the first name in the Mac Contacts application that has the phone number I’m searching for.
>
> [...]
>
> This script does NOT work to find every contact by phone number and results in the error below. What am I doing wrong?
> tell application "Contacts"
> get name of first person whose phone contains "805"
> end tell
Hello Bill,
I'm a bit late and you already got a lot of replies.
Anyway, here's an additional approach, supposed to let Contacts do all the hard work:
tell application "Contacts"
people whose (class of (first phone whose value contains "805") is phone)
end tell
Seems to be fine here, on 10.8.5.
As far as efficiency is concerned... I don't know: I've only a little list of contacts...
Fetching the name of the first person meeting the search criterion is just a matter of replacing "people whose ..." by " name of first contact whose ..." (with some provision for the "not found" case, of course).
Anecdotally,
Axel
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden