Quickly Change Filtering

Is there a quick way to change filtering in OmniFocus 2? I find the animation that brings up the View Options to be interminably slow. Add to that visually finding the section I want (i.e. Filter by Availability) and the process seems much more cumbersome than in OF 1. I would love to have either Toolbar buttons or menu options to be able to quickly change the filtering settings.

Is it possible to use AppleScript to control such things? My AppleScript skills are severely lacking, but maybe I could hack something together.

I guess this AppleScript called “CycleTaskStates” might be what you are looking for.
I have it triggered by this combination and it works well with both OF1 and OF2.

You can find this and other useful scripts here

I liked the way this script provided a popup list with choices

I hacked it up further

set theList to {"1 Flagged and Available"}
set theList to theList & {"2 Available"}
set theList to theList & {"3 Flagged and Remaining"}
set theList to theList & {"4 Remaining"}
set theList to theList & {"---------"}
set theList to theList & {"5 unflagged and available"}
set theList to theList & {"6 unflagged and remaining"}
set theList to theList & {"---------"}
set theList to theList & {"7 all"}
choose from list (theList) with prompt "Choose a filter toggle:" with title "OmniFocus Filterer"
set myAnswer to result as text

tell application "OmniFocus"
	set theDoc to document window 1 of document 1
	--set selected trees of sidebar to sidebar -- deselects everything
	if myAnswer contains "1" then
		set selected task state filter identifier of the content of theDoc to "available"
		set selected task flagged filter identifier of the content of theDoc to "flagged"
	end if
	if myAnswer contains "2" then
		set selected task state filter identifier of the content of theDoc to "available"
		set selected task flagged filter identifier of the content of theDoc to "all"
	end if
	if myAnswer contains "3" then
		set selected task state filter identifier of the content of theDoc to "incomplete"
		set selected task flagged filter identifier of the content of theDoc to "flagged"
	end if
	if myAnswer contains "4" then
		set selected task state filter identifier of the content of theDoc to "incomplete"
		set selected task flagged filter identifier of the content of theDoc to "all"
	end if
	if myAnswer contains "5" then
		set selected task state filter identifier of the content of theDoc to "available"
		set selected task flagged filter identifier of the content of theDoc to "unflagged"
	end if
	if myAnswer contains "6" then
		set selected task state filter identifier of the content of theDoc to "incomplete"
		set selected task flagged filter identifier of the content of theDoc to "unflagged"
	end if
	if myAnswer contains "7" then
		set selected task state filter identifier of the content of theDoc to "all"
		set selected task flagged filter identifier of the content of theDoc to "all"
	end if
end tell

Thanks everybody. I also hacked together a little script. I have no idea what I’m doing in Applescript, but it seems to do the trick.

    tell application "OmniFocus"
	tell content of first document window of front document
		
		-- this gives a list of acceptable identifiers
		-- set myList to available task state filter identifiers
		
		set currentState to selected task state filter identifier
		if currentState contains "available" then
			set properties to {selected task state filter identifier:"incomplete"}
		else
			set properties to {selected task state filter identifier:"available"}
		end if
	end tell
end tell

Thank you so much for the scripts. I’ve modified a couple from your page for my purposes and they work beautifully.

Glad you found it useful. It’s just not my page. I just pointed you to it ;-)