View Single Post
Hi,

I would need some help to use the duplicate command to duplicate a single task.

Here is what I got so far:
The [...] is the not relevant code that has been stripped out

Code:
property WForContext : "WFor"

tell application "OmniFocus"
	-- [...]
	tell front document
		tell document window 1
			set theSelectedItems to selected trees of content
		end tell
	end tell
	
	set theSelectedTask to value of item 1 of theSelectedItems
	
	set MyDoc to first document
	tell MyDoc
		-- [...]
		set contextList to complete WForContext as context maximum matches 1
		
		-- [..]
		set theWForContext to context id (id of item 1 of contextList)
		-- PROBLEM: what is the "to" arg expecting?
		-- (Arg that is optional according to the doc, but is expected by OF - Bug filled to support Ninjas)
		
		set theResult to duplicate (theSelectedTask) to (after last task) with properties {context:theWForContext}
		
		-- [..]
		
	end tell
	-- [..]
end tell
Any help would be greatly appreciated.