Need help to add calendar selection to an Add a calendar event AppleScript

Hello all!

I have a AppleScript that asks the user for event info through AppleScript dialogs, and it then creates an event into Calendar. It works well, but I want to add the option to select which calendar the event is added into.

Here is the working script:

set theDate to short date string of (current date)

display dialog "Enter the event:" default answer "Rock the universe!"
set eName to text returned of the result

display dialog "Enter the date:" default answer (theDate as text)
set eDate to text returned of the result

display dialog "Enter start time:" default answer "1:00 pm"
set eTime to text returned of the result
set eStart to date (eDate & space & eTime)
set eEnd to (date (eDate & space & eTime)) + (1 * hours)

display dialog "Enter the description:" default answer "→ "
set eDesc to text returned of the result

display dialog "Enter a link:" default answer "http://"
set eURL to text returned of the result

display dialog "Enter a reminder time" default answer "-15"
set eRemind to text returned of the result

tell application "Calendar"
	tell calendar "Things"
		set theCurrentDate to current date
		set newEvent to make new event at end with properties {description:eDesc, summary:eName, location:"Work", start date:eStart, end date:eEnd, url:eURL}
		tell newEvent
			make sound alarm at end of sound alarms with properties {trigger interval:eRemind, sound name:"Crystal"}
		end tell
	end tell
end tell

And here is the code hat I am working on, which gets the list of calendars from Calendar, and retunes the select calendar:

tell application "Calendar"
	set CalList to name of every calendar
	set ChosenCal to choose from list CalList with title "List of Calendars" with prompt "Please choose a calendar:" default items "Things" OK button name "Choose"
end tell

How to I merge these into one script?

1 Like

set newEvent to make new event in calendar “ChosenCal” at end with properties {description:eDesc, summary:eName, location:“Work”, start date:eStart, end date:eEnd, url:eURL}`

1 Like

I removed the quotes around the variable ChosenCal and all s good. Kudos!

Thank you Jean Christophe! That helped me get past my blockage!

1 Like

Yes, indeed. The quotes were in my code because I work with only one calendar. Sorry for that.

1 Like