View Single Post
Originally Posted by Mburch View Post
What about adding a duration to the script?
In the script you would add an additional condition for the task duration.

Example 15 minutes:
tell (make new task with properties {name:task_title, context:oContext, start date:dteStart, due date:dteDue, flagged:true, estimated minutes:”15”})
You can adjust the duration to the length of time you want.

Originally Posted by Mburch View Post
Also, how would you add a Project that is part of a hierarchy? So rather than Finance in David Sparks example, how would you add Finance if it was under Personal projects? "Personal:Finance" does not seem to work.
It is unclear what your hierarchy is. Is “Personal” a project or a folder; and the same with "Finance"? If you have separated "Personal" and "Professional" projects by use of folders and have a "Finance" project within each the script finds the first project matching the name "Finance" and inserts the new task.

Regardless, you could state specifically the folder you wish to add a task to the project "Finance".

Simple example:
set theDate to current date
set theTask to "New Task"
set theDuration to "15"

tell application "OmniFocus"
	tell front document
		set theContext to first flattened context where its name = "Mac"
		set theFolder to first flattened folder where its name = "Personal"
		set theProject to first flattened project of theFolder where its name = "Finance"
		tell theProject to make new task with properties {name:theTask, estimated minutes:theDuration, context:theContext}
	end tell
end tell