View Single Post
Quote:
Originally Posted by skillet View Post
Do you have an example of the complete script you are using by chance? Also does the script only work if run in Project view?

Check out post 8 by Bill!
http://forums.omnigroup.com/showthread.php?t=22073
Here's code that will copy a list of selected tasks , or an individual task, to non repeating and remove flags if any. The original task is marked as completed.

It works for me in context and project modes.


Code:
tell application "OmniFocus"
	activate
	tell default document
		set FrontWindow to first document window whose index is 1
		tell FrontWindow
			
			if ((count of leaves of selected trees of content) is 0) then
				set theItems to value of selected trees of content
			else
				set theItems to (value of leaves of selected trees of content) as list
			end if
			
			
			repeat with anItem in theItems
				if (class of anItem) is list then
					repeat with subItem in anItem
						if (class of subItem is task) then
							
							set newitem to duplicate subItem to after subItem
							set repetition of newitem to missing value
							set flagged of newitem to false
							set completed of subItem to true
							
						end if
					end repeat
					
				else if (class of anItem is task) then
					set newitem to duplicate anItem to after anItem
					set repetition of newitem to missing value
					set flagged of newitem to false
					set completed of anItem to true
					
				end if
			end repeat
		end tell
	end tell
end tell