AppleScript – Update Contacts app by reference to their ID

I've been using AppleScript to create new people in the Address Book/Contacts app on my Mac running macOS Monterey 12.6. I've been storing their IDs (e.g. 778C4D8D-0A22-4918-A5B6-73361FFF8779) and I now need to create a version of the AppleScript that will perform an update of the Contacts app record using their Contacts app ID as the identifier for which person to update.

Here's my AppleScript for creating a new person:

tell application "Contacts"

set thePerson to make new person with properties ¬
    {first name:"Dee", last name:"Velhopa", organization:"Paws On Error"} ¬
make new email at end of emails of thePerson with properties ¬
    {label:"Work", value:"dee@pawson.error"}
make new phone at end of phones of thePerson with properties ¬
    {label:"Work", value:"+44 0161 715 7028"}
make new url at end of urls of thePerson with properties ¬
    {label:"Work", value:""}
make new address at end of addresses of thePerson with properties ¬
    {label:"Work", street:"MellowBank", city:"Bored End", state:"Bucks", zip:"SL8 5AJ", country:"U.K."} ¬

end tell

I haven't been able to work out how to modify this so that if I have their ID to simply do an update with the same data but not create a new person.

Author: Subham

Leave a Reply

Your email address will not be published. Required fields are marked *