Re: Search Contacts for phone number
Re: Search Contacts for phone number
- Subject: Re: Search Contacts for phone number
- From: Shane Stanley <email@hidden>
- Date: Mon, 22 Sep 2014 10:14:23 +1000
On 22 Sep 2014, at 7:33 am, Bill Vlahos <email@hidden> wrote:
This script works to find every contact by name.tell application "Contacts" get name of first person whose name contains "Bill" end tell
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
Name is a property, but phone is an element -- whose clauses only work with properties. A person can have more than one phone, and phones have values and labels, so you're going to have to do some looping. This should do what you want:
tell application "Contacts" repeat with aPerson in people set theNumbers to value of aPerson's phones repeat with aNumber in theNumbers if aNumber contains "805" then return aPerson's name end if end repeat end repeat end tell
|
_______________________________________________
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