View Single Post
I don't think that there is any way of avoiding the fact that dragging focused projects to new relative positions will drag them out of their folders.

Might be worth a request to the Ninjas through Help > Send Feedback ...

In the meanwhile, I think you can probably make the script a bit simpler and faster by rewriting it along these lines:

property pTitle : "Focus on flagged projects"

tell application id "OFOC"
	tell default document
		set refProjects to a reference to (flattened projects where (flagged is true) and ((status is active) or (status is on hold)) and ((its folder is missing value) or ((effectively hidden of its folder) is false)))
		set {lstID, lstName} to {id, name} of refProjects
		set lstProjects to contents of refProjects
		set focus of front document window to lstProjects
		if length of lstProjects < 1 then
			display dialog "No flagged projects found" buttons "OK" default button "OK" with title pTitle
		else -- Place linked MarkDown text in Clipboard
			set strMK to ""
			repeat with i from 1 to length of lstID
				set strMK to strMK & "*" & tab & "[" & item i of lstName & "](omnifocus:///task/" & item i of lstID & ")" & return & return
			end repeat
			tell application id "MACS" to set the clipboard to strMK
		end if
	end tell
end tell

Last edited by RobTrew; 2012-05-04 at 08:17 AM.. Reason: Edited code to properly handle projects not in folder, and place linked Markdown text in clipboard