Is there a simple way to determine the calendar for a selected event?

If I know the id of an event, is there a simple way to determine the Calendar it belongs to? I want to retrieve properties of the selected event in iCal without caring what calendar the event belongs to.

I am aware of ways of doing this using CalendarLib, just wondering if there is a simpler way (see forum-latenightsw-com/t/how-do-i-get-selected-event-in-apple-calendar/2114/4 )

set defaultsReply to (do shell script "defaults read com.apple.ical SelectedEvents")

set localUIDs to {}
set {TID, text item delimiters} to {text item delimiters, quote}
set resultItems to text items of defaultsReply
set text item delimiters to TID
repeat with i from 1 to (count resultItems)
	if i mod 2 = 0 then set end of localUIDs to resultItems's item i
end repeat


tell application id "com.apple.iCal" -- Calendar
	set theProps to properties of event id (item 1 of localUIDs) of calendar "Work"
end tell

If all you need are the properties of an event, you don’t need to know the calendar name. You can use this syntax to lookup the event in any calendar:

tell application "Calendar"
	properties of event id "1FE923B3-B572-4912-8628-7A925C8CA4FC" of some calendar
end tell
1 Like

Thanks Mark, that was exactly what I was looking for. Perfect. So I now have a script that will retrieve last/current selected event (even if Calendar is closed) and retrieve properties of same.