The Omni Group
These forums are now read-only. Please visit our new forums to participate in discussion. A new account will be required to post in the new forums. For more info on the switch, see this post. Thank you!

Go Back   The Omni Group Forums > OmniFocus > OmniFocus Extras
FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
Mass de-flag in context/perspective script. Thread Tools Search this Thread Display Modes
Ho-ho-hello. Getting ready for 012. My desperate daily workflow requires a script that will un-flag ALL items in a given Context/Perspective. Willing to fund a PayPal account. pls help. thx.
 
I think you should be able to deflag everything that is shown in a particular perspective with something like this.

Code:
tell application id "OFOC"
	tell front document window of front document
		set refTrees to a reference to trees of content
		
		-- UN-FLAG ANY VISIBLE PROJECTS
		repeat with oProj in (value of refTrees where class of its value is project) as list
			set flagged of oProj to false
		end repeat
		
		-- TOP LEVEL TASKS
		repeat with oValue in (value of refTrees where class of its value is task) as list
			my ClearFlag(oValue)
		end repeat
		
		--  AND CHILD TASKS 
		-- if we are grouping by flag, the Flagged tree may vanish at run time
		repeat with i from (count of refTrees) to 1 by -1
			set oTree to item i of refTrees
			repeat with oTask in (value of descendant trees of oTree) as list
				my ClearFlag(oTask)
			end repeat
		end repeat
		
		-- WORKING AROUND AN OMNIFOCUS GUI BUG ...
		-- Note a bug in the GUI: project flags will not appear as cleared until the window is closed & reopened
		--  the following simply the view mode back and forth to force a repaint
		-- a time-waster, but works around the GUI bug
		set lstView to available view mode identifiers
		if item 1 of lstView = selected view mode identifier then set lstView to reverse of lstView
		repeat with oView in lstView
			set selected view mode identifier to oView
		end repeat
	end tell
end tell

on ClearFlag(oTask)
	tell application id "OFOC"
		set flagged of oTask to false
		set oParent to container of oTask
		repeat while class of oParent is in {task, project}
			set flagged of oParent to false
			set oParent to container of oParent
		end repeat
	end tell
end ClearFlag
Note that OmniFocus still seems to have a screen refresh bug - when the flagging of a Project is cleared by script, the flag icon is not immediately repainted/cleared - you have to close and reopen the window to see what has really happened.
Flags on cleared tasks, however, should immediately vanish.

I remember this bug from years ago, so I am a bit surprised to notice that it is still there. Certainly worth a bug report through OF > Help > Send Feedback ...

--

Last edited by RobTrew; 2012-01-25 at 08:51 PM.. Reason: Amended code to clear project flags in Context view
 
Thank you!!!
 
Hi there! Thank you again for providing this script.

Since I use the script almost exclusively in context mode, I thought I would offer a little feedback on its usage.

- The script indeed successfully de-flags tasks in my context/perspective. I immediately see the flag disappear, and all I have to do is "clean up" and I get the result I desire. I am curious if we can script the "clean up" part?

- However, the script does not de-flag Projects. It also does not de-flag tasks inside Projects that are flagged (auto-flagged tasks). Again, I am operating from context mode.

Do you have any additional suggestions on how I can achieve a full de-flagging of all objects in a given context/perspective?

Thank you! RT
 
Thanks for pointing that out.

Amended above, and should now clear project flags from Context view as well.
 
Further amended above - thanks to some very thoughtful and ingenious debugging by whpalmer4.
 
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Auto-Flag by Context Juandp77 OmniFocus Extras 6 2013-03-22 09:04 AM
Searching for script to convert project-based perspective to context one vitvit2002 OmniFocus Extras 0 2013-02-03 11:58 PM
setting project + context via script (modifying a DEVONthink script) bernd OmniFocus Extras 2 2012-09-08 12:10 PM
iOS5 Killer addition > You can flag mails > You can script mail rule to add to OF :)) stevenjohn OmniFocus for iPad 16 2012-08-07 09:24 AM
Due and Flag Perspective ade Applying OmniFocus 8 2009-05-09 05:53 AM


All times are GMT -8. The time now is 12:33 PM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2024, vBulletin Solutions, Inc.