View Single Post
I know this is not a full solution, but I thought you might be interested in two associated articles and scripts for creating tasks in OmniFocus via Hazel.

The first is the original David Sparks script. From this blog post http://macsparky.com/blog/2012/8/app...mnifocus-tasks

Code:
-- Lovingly crafted by David Sparks, The Omni Group, and Ben Waldie -- macsparky.com

set theDate to current date
set theTask to "Pay Life Insurance"
set theNote to "Lovingly Scanned by your Mac on " & (theDate as string)

tell application "OmniFocus"
    tell front document
        set theContext to first flattened context where its name = "Tech"
        set theProject to first flattened project where its name = "Finance"
        tell theProject to make new task with properties {name:theTask, note:theNote, context:theContext}
    end tell
end tell
The second is from Patrick Lenz who modified David Sparks script. From this blog post http://patricklenz.com/posts/create-...a-hazel-redux/

Code:
tell application "Finder" to set file_name to (name of theFile)

tell application "OmniFocus"
    set task_title to "Pay " & file_name
    tell default document
        set newTask to make new inbox task with properties {name:task_title}
        tell the note of newTask
            make new file attachment with properties {file name:theFile, embedded:false}
        end tell
    end tell
end tell
I tried combining these two scripts, but could at most only get a task with an attachment and a context into the inbox. This was what I have so far.

Code:
tell application "Finder" to set file_name to (name of theFile)

tell application "OmniFocus"
	set task_title to "Pay " & file_name
	tell default document
		set theContext to first flattened context where its name = "iMac"
		set newTask to make new inbox task with properties {name:task_title, context:theContext}
		tell the note of newTask
			make new file attachment with properties {file name:theFile, embedded:false}
		end tell
	end tell
end tell
I can get a task with attachment and context into the inbox. The addition of sending it to a project per the method from the David Sparks script does not work.

To get the obvious out of the way yes, I did replace the "make new inbox task" with "make new task" when testing this with a line similar to

Code:
set theProject to first flattened project where its name = "Finance"
All comment and suggestions welcome.

Thank you in advance.