Hi, I have a problem whith clearing alarms on the Catalina system.
example.
tell application “Calendar”
tell calendar “TsCalendar”
set Myevents to first event
set MyAlarm to every sound alarm of Myevents
if MyAlarm is not {} then
tell Myevents
delete every sound alarm
end tell
end if
end tell
end tell
Event :
tell application “Calendar”
get event 1 of calendar “TsCalendar”
get every sound alarm of event id “D0FA5BF2-026D-4327-8590-68F0FB890213” of calendar id “7ED62731-DC0B-4E0B-8498-D56D5A0BEF25”
delete every sound alarm of event id “D0FA5BF2-026D-4327-8590-68F0FB890213” of calendar id “7ED62731-DC0B-4E0B-8498-D56D5A0BEF25”
Result:
error “Calendar ha trovato un errore: L’handler dell’AppleEvent non è riuscito.” number -10000
Any idea to delete alarm ?
Thanks.
For testing I used:
tell application "Calendar"
(get name of calendars) --> {"Work", "Sports", "Anniversaires", "Jours fériés français"}
tell calendar "Anniversaires" -- "TsCalendar"
set Myevents to first event
set MyAlarm to every sound alarm of Myevents
if MyAlarm is not {} then
tell Myevents
delete every sound alarm
end tell
end if
delay 0.5
set MyAlarm to every sound alarm of Myevents
end tell
end tell
The Log History was :
Don't click upon [Open this Scriplet in your Editor:], here is just a Log History
tell application "Calendar"
get name of every calendar
--> {"Work", "Sports", "Anniversaires", "Jours fériés français"}
get event 1 of calendar "Anniversaires"
--> event id "20F65FA2-87CF-436B-8A86-8F1153DE4F0D" of calendar id "6C6565AA-8179-42AD-AB29-AA5F5EC1D8A7"
get every sound alarm of event id "20F65FA2-87CF-436B-8A86-8F1153DE4F0D" of calendar id "6C6565AA-8179-42AD-AB29-AA5F5EC1D8A7"
--> {sound alarm 1 of event id "20F65FA2-87CF-436B-8A86-8F1153DE4F0D" of calendar id "6C6565AA-8179-42AD-AB29-AA5F5EC1D8A7"}
delete every sound alarm of event id "20F65FA2-87CF-436B-8A86-8F1153DE4F0D" of calendar id "6C6565AA-8179-42AD-AB29-AA5F5EC1D8A7"
get every sound alarm of event id "20F65FA2-87CF-436B-8A86-8F1153DE4F0D" of calendar id "6C6565AA-8179-42AD-AB29-AA5F5EC1D8A7"
--> {sound alarm 1 of event id "20F65FA2-87CF-436B-8A86-8F1153DE4F0D" of calendar id "6C6565AA-8179-42AD-AB29-AA5F5EC1D8A7"}
end tell
Résultat :
{sound alarm 1 of event id "20F65FA2-87CF-436B-8A86-8F1153DE4F0D" of calendar id "6C6565AA-8179-42AD-AB29-AA5F5EC1D8A7" of application "Calendar"}
So, it appears that with 10.13.6, we got no error but the sound wasn’t removed.
You may study this draft using Shane Stanley’s CalendarLib EC library.
use AppleScript version "2.5" -- requires OS X 10.11 or higher
use scripting additions
use framework "Foundation"
use framework "EventKit"
use script "CalendarLib EC"
tell application "Calendar"
(get name of calendars) --> {"Work", "Sports", "Anniversaires", "Jours fériés français"}
tell calendar "Anniversaires" -- "TsCalendar"
set myEvents to events
repeat with anEvent in myEvents
log (get start date of anEvent)
log (get end date of anEvent)
log (get description of anEvent)
log (get recurrence of anEvent)
end repeat
end tell
end tell
set d1 to current date
set d2 to d1 + 100 * days
set theStore to fetch store
set theCal to fetch calendar "Anniversaires" cal type cal birthday event store theStore
set theEvents to fetch events starting date d1 ending date d2 searching cals {theCal} event store theStore
repeat with anEvent in theEvents
log (event info for event anEvent)
log (event identifier for event anEvent)
log (event attendees for event anEvent)
log (event recurrence for event anEvent)
end repeat
repeat with anEvent in theEvents
if (anEvent's hasAlarms()) then
set theAlarms to (anEvent's alarms())
repeat with anAlarm in theAlarms
(anEvent's removeAlarm:anAlarm)
end repeat
delay 0.2
-- check that the alarms are really gone
log (anEvent's hasAlarms()) --> false
end if
end repeat
Yvan KOENIG running High Sierra 10.13.6 in French (VALLAURIS, France) mercredi 8 janvier 2020 19:25:59
thank you so much for the quick reply.
But I was looking for a way to delete alarms using Native Applescript only.
On Catalina, however, I am notified of an error in the attempt to cancel an alarm
I understood what you wrote in your original message…
If, as I assume, you are facing a bug in Catalina, you will have to live with it until it’s killed or try to solve the problem with an auxiliary tool.
I’m surprised to see that nobody running Catalina posted a message here.
Yvan KOENIG running High Sierra 10.13.6 in French (VALLAURIS, France) mardi 14 janvier 2020 11:01:38