Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

When a contact card is displayed, how can I tell which sub-group that contact is in?

When contact card displayed, how do I determine which Group that contact is in? In my address book, when I search for a contact in All Contacts, and the card is displayed, how can I then tell which Group (or groups) that contact is in?

MacBook

Posted on Dec 1, 2012 5:38 AM

Reply
3 replies

Dec 1, 2012 11:25 AM in response to Janice1758

Here's an AppleScript that will do show all groups belonged to by the selected person


tell application "Address Book"

set nameList to {}

set thisPerson to selection


set groupList to properties of groups of (item 1 of thisPerson)

set numberOfGroups to count of groupList

repeat with i from 1 to numberOfGroups

set groupName to (get name of item i of groupList) as string

set nameList to nameList & groupName

end repeat


return nameList


end tell


If you're not familiar with AppleScripts, launch Applications -> Utilities -> AppleScript


copy and paste the above script into the AppleScript editor


click the <Compile> button to verify syntax


Now, to run the script, Open the Address Book and select a contact from "All Contacts"


now run the script.

Dec 1, 2012 11:33 AM in response to Janice1758

Here's one that doesn't require the Address Book application to be launched


display dialog "Please enter first name of contact:" default answer "First Name"

set firstName to text returned of result

display dialog "Please enter the last name of contact:" default answer "Last Name"

set lastName to text returned of result


tell application "Address Book"

set nameList to {}


(* set thisPerson to selection *)

set thisPerson to every person whose first name is firstName and last name is lastName


set groupList to properties of groups of (item 1 of thisPerson)

set numberOfGroups to count of groupList

repeat with i from 1 to numberOfGroups

set groupName to (get name of item i of groupList) as string

set nameList to nameList & groupName

end repeat


return nameList


end tell

When a contact card is displayed, how can I tell which sub-group that contact is in?

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.