Although the Calendar Application will create a new event with a url, if Calendar creates that event, it will not edit that event to associate a url if EventKit created it. Likewise I cannot script EventKit, via Shane’s CalendarLib EC to create an event with a url property and value.
Creating an event and associating a url with it in AppleScript works without error.
use scripting additions
tell application "Finder"
set Finder_Selection to selection as alias
set Finder_Item_Name to name of Finder_Selection
set Finder_URL to URL of Finder_Selection
end tell
set theSummary to Finder_Item_Name
set theDescription to "To Do"
set d1 to current date
set d2 to d1 + 1 * hours
tell application "Calendar"
tell calendar "Work"
--delete (every event whose summary is theName)
set theEvent to make new event with properties {start date:d1, allday event:true, summary:theSummary, url:Finder_URL, description:theDescription}
activate
show theEvent
end tell
end tell
However, when I script EventKit via Shane’s CalendarLib EC to create an event, I cannot find a method to set a url to that event, and I cannot find a manner in which the Calendar Application can edit that event to set a file url.
use scripting additions
use framework "Foundation"
use script "CalendarLib EC"
tell application "Finder"
set Finder_Selection to selection as alias
set Finder_Item_Name to name of Finder_Selection
set Finder_URL to URL of Finder_Selection
end tell
set theSummary to Finder_Item_Name
set theDescription to "To Do"
set d1 to current date
set d2 to d1 + 1 * hours
set theStore to fetch store
set theCal to fetch calendar "Work" cal type cal cloud event store theStore
set theEvent to create event event store theStore ¬
destination calendar theCal ¬
event summary theSummary ¬
starting date d1 ¬
ending date d2 ¬
event location "Office" event description theDescription ¬
without runs all day
store event event theEvent event store theStore
--I cannot find a method to define an event URL via Shane's CalendarLib EC or via Objective C, or a method to convert the EventKit output into an event that Calendar recognizes.
tell application "Calendar"
tell event theEvent
set its url to Finder_URL --> errors
end tell
end tell
--application "Calendar" errs.
I think that the second script errs as it fails to convert the EventKit output into a Calendar Application event id.
I have 3 questions.
- Does an event created by EventKit or Shane’s CalendarLib EC possess a url property?
- If so, what is the method to have Shane’s CalendarLib EC, or EventKit on its own, set that event url property to a file location?
- If not, what is the method to convert the EventKit output into an identifiable event that the Calendar Application can recognize?
Model: MacBook Pro
AppleScript: 2.5
Browser: Safari 600.5.17
Operating System: Mac OS X (10.10)