View Single Post
At 'at' needs to be a fully fledge location specifier relative to the enclosing 'tell' block. Right now (at least) a 'document' doesn't really have tasks -- that the relationship exists is an implementation details to make 'id' specifiers work nicely. Sadly, there isn't a good way to document this in the suite.

With a task selected in project mode, this works for me. Of course, this will fail if you have an inbox task, project, or collation group selected. Also, you might want it to copy inside the parent task group if any, but this is a starting point =)

It looks like the 'with properties' isn't working on 'duplicate' right now. I've logged a bug on this.

Code:
tell application "OmniFocus"
	tell default document
		tell document window 1
			set theSelectedItems to selected trees of content
		end tell
		set theSelectedTask to value of item 1 of theSelectedItems
		set theResult to duplicate theSelectedTask to end of tasks of containing project of theSelectedTask with properties {context:context "cc"}
	end tell
end tell
__________________
CTO, The Omni Group