Sent tasks to a from TBX to OmniFocus Project

Found this thread while searching for an answer to send dates to Omnifocus via applescript.

I have a workaround.

I start by formatting Tinderbox’s date by creating user attribute $DueDateLong (string). The rule for the note: $DueDateLong=($DueDate.format(“L”) + " at 6:00:00 PM");
Which gives me “29 September 2023 at 6:00:00 PM”. This string can be converted to date-type in applescript (not sure if I used the right terms in applescript-speak).

(I hard code 6pm because that’s my default due time in Omnifocus and I don’t set the time in Tinderbox. But I’m sure you can just code the date.format to include the time too.)

tell application "Tinderbox 9"
	tell front document's selection
		set noteName to name
		set dueDateString to (value of (attribute named "DueDateLong")) as string
		set startDateString to (value of (attribute named "StartDateLong")) as string
		set timeEstimate to value of (attribute named "TimeEstimate")
		set noteURL to value of (attribute named "NoteURL")
	end tell
end tell

#I'm unsure why this has to be isolated to work
set dueDate to date dueDateString
set startDate to date startDateString

tell application "OmniFocus"
	tell front document
		set theTask to make new inbox task with properties {name:noteName, defer date:startDate, due date:dueDate, estimated minutes:timeEstimate, note:noteURL}
		set omniTaskID to id of theTask
	end tell
end tell

tell application "Tinderbox 9"
	tell front document's selection
		set value of (attribute named "OmniFocus") to ("omnifocus:///task/" & omniTaskID)
	end tell
end tell

The bulk of the script is taken from An Applescript that creates an Omnifocus project from a Tinderbox Note and reciprocally links them.

2 Likes