Need help with an AppleScript to create an Omnifocus task via Hazel

Hi everyone, I am not a programmer and I don’t know AppleScript and am hoping that some kind soul here can help me with this.

I want to automatically create a task in OF to review a document that lands in a certain folder (using Hazel).
I’ve found this script that works, but I would like to have the task land in a specific OF project (“SD Review” that exists) as opposed to the Inbox (apologize if I didn’t paste in the correct formatting - I’m trying!!):

tell application “Finder” to set file_name to (name of theFile)
tell application “OmniFocus”

set task_title to "Review inbox file - " & 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

Thank you again for reading this and for any help.

This should do it:

tell application "Finder" to set file_name to (name of theFile)
tell application "OmniFocus"
	set task_title to "Review inbox file - " & file_name
	tell default document
		set theProject to first flattened project where its name = "SD Review"
		tell theProject
			set newTask to make new 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
end tell

(re formatting, if you use three backticks (```) on one line, then paste the code, and then the same after the final line, the code will show properly.) :slight_smile:

1 Like

Kaitlin- thank you so so much. You are my hero!! Works great