I took a look at your code. I don't think that I have the whole answer, but I was getting
an error adding a group and I don't have CardDAV, but I did get the code to work.
tell application "Contacts"
set fullName to {first name:"Joe", last name:"Bloe"}
# create a new person object
# TODO: If there is already a person with the same first and last name, it would
# be good to ask the user for a confirmation before creating a new person
set thePerson to make new person with properties fullName
make new phone at end of phones of thePerson with properties {label:"mobile", value:"0422123456"}
make new email at end of emails of thePerson with properties {
label:"Work",
value:"
email@hidden"}
# create a group called "TestGroup" (if it doesn't already exist)
set theGroupName to "TestGroup"
if not (group theGroupName exists) then
set theGroup to make new group with properties {name:theGroupName}
end if
# add thePerson to theGroup
add thePerson to group theGroupName
# save all changes
save
end tell
I think that it is helpful to check if a group by that name already exists before trying
to create a group with the same name.
I think too, that when there is already a person with the same first and last
names that the script should ask the user for a confirmation before adding
a new person with the same name as an existing person in Contacts.
But, I wasn't able to do this.
-- Kaydell
Hi all,
Im fairly new to applescript, although i have successfully added a new contact to the contacts app locally however i can not get it to add the contact to the carddav account or in the group of the carddav account.
My code so far is
tell application "Contacts"
set thePerson to make new person with properties{first name:"Joe", last name:"Bloe"}
make new phone at end of phones of thePerson with properties{label:"mobile", value: "0422123456"}
make new email at end of emails of thePerson with properties{label:"Work", value: "
email@hidden"}
save
end tell
If i try to do
add thePerson to group "TestGroup"
With TestGroup being a group in the carddav account the error i get is
Contacts got an error: You can only add a person to a group.
The machine i am using is the carddav server as well.
I am also using the latest version of os x. 10.8.4 with all software updates completed.
With Thanks
Brendon Schodel
--
Shoddy
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