Hello,
Here is my code in AppleScript to duplicate a selected tree in OmniFocus.
tell application "OmniFocus"
tell the front document
tell the document window 1
set the_selected_tree to a reference to selected tree of content
set the_duplication to duplicate the_selected_tree
end tell
end tell
end tell
And I got an error which says 'the Apple Event handler failed (errAEEventFailed:-10000)
What’s wrong with it?
Thanks,
Is this part of a longer AppleScript? From the keyboard you can use ⌘D to duplicate any item or tree in the outline.
I borrowed some of @curt’s handy Complete and Await Reply script to provide you with a way of duplicating a selected tree. Although not being a programmer, I think OF was needing your script to tell it to recurse through the child tasks of the selected parent.
tell application "OmniFocus"
tell the front document
tell content of document window 1 -- (first document window whose index is 1)
set theSelectedItems to value of every selected tree
if ((count of theSelectedItems) < 1) then
display alert "You must first select an item to complete." as warning
return
end if
repeat with anItem in theSelectedItems
set itemTitle to name of anItem
set theDupe to duplicate anItem to after anItem
end repeat
end tell
end tell
end tell