This simplistic script will populate the entry dialog of Fantastical 2 with the name of the currently selected item in DEVONthink and, optionally, the item link of that item. Select an item and run the script. (I install this script in my toolbar for easy access.) A dialog will open with the item name and optional item link. Fantastical uses a plain language parser so change the dialog content in whatever way you wish in order to prime the Fantastical entry. The dialog lets you choose whether to add the entry immediately to Fantastical 2, or to open Fantastical 2’s menu bar dialog so you can adjust other Fantastical 2 options if you wish. The addition of the item link is controlled by the “itemLink” property which is “true” by default – meaning the link is part of the proposed calendar entry. With the link then you can click the URL field in the calendar and open that document in DEVONthink.
I have configured Fantastical 2 to sync calendars and reminders with BusyCal and Apple Calendar – so what happens in Fantastical 2 happens every where.
This is provided as is and support is probably not going to happen
property itemLink : true -- when true: include the DEVONthink item link (reference URL)
tell application id "DNtp" -- DEVONthink
try
set theSelection to the first item of (the selection as list)
if theSelection is {} then error "Please select something"
set theName to the name of the theSelection
if itemLink then
set theURL to " " & the reference URL of theSelection
else
set theURL to ""
end if
set theString to theName & theURL
set theResult to (display dialog "Edit the following if you wish" default answer theString buttons {"Add immediately", "Open in Fantastical", "Cancel"} default button 3 cancel button 3 with title "Create a Fantastical 2 entry")
set theText to text returned of theResult
set theButton to button returned of theResult
tell application id "fCl2" -- Fantastical 2
if theButton is "Add immediately" then parse sentence theText with add immediately
if theButton is "Open in Fantastical" then parse sentence theText
end tell
on error error_message number error_number
if the error_number is not -128 then display alert "DEVONthink Pro" message error_message as warning
end try
end tell
Here is the script’s dialog, on the left, and the Fantastical 2 dialog on the right. Fantastical 2 parses entries and figures out what to do. Please read Fantastical 2’s help and tutorials if you need to figure how to use that program.