Skip to content

Instantly share code, notes, and snippets.

@pdxmph
Last active April 27, 2023 18:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pdxmph/395302a6122eabe39c6cb6d8f0e14360 to your computer and use it in GitHub Desktop.
Save pdxmph/395302a6122eabe39c6cb6d8f0e14360 to your computer and use it in GitHub Desktop.
Half-working contact update
-- provided there's a custom date field in a contact record, this will prepend a datestamped note and update "last contacted" to today.
set theDate to do shell script "date +%Y-%m-%d"
tell application "Contacts"
set selectedPeople to selection
repeat with thePerson in selectedPeople
set customDates to custom dates of thePerson
repeat with aCustomDate in customDates
if label of aCustomDate is "last contacted" then
set value of aCustomDate to current date
end if
end repeat
set theNote to note of thePerson as string
set prependText to text returned of (display dialog "Enter text to prepend to the note of " & name of thePerson & ":" default answer "" buttons {"Cancel", "OK"} default button "OK" cancel button "Cancel")
set noteUpdated to "[" & theDate & "] " & prependText & return & theNote & return & " " & return
set note of thePerson to noteUpdated
save thePerson
end repeat
end tell
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment