A slightly clunky GUI scripting workaround, relevant code snippets below:
set availableTaskStates to {"next", "available", "complete", "remaining"} --"all" no longer available
set nextTaskState to choose from list availableTaskStates
if nextTaskState contains "next" then set nextTaskState to "Availability: F"
if nextTaskState contains "available" then set nextTaskState to "Availability: A"
if nextTaskState contains "complete" then set nextTaskState to "Availability: C"
if nextTaskState contains "remaining" then set nextTaskState to "Availability: R"
tell application "System Events"
keystroke "v" using { command down, shift down }
repeat 8 times
keystroke tab
end repeat
keystroke nextTaskState
delay 2.5
keystroke "v" using { command down, shift down }
end tell
This only works if you’ve upgraded the perspective and the availability selection is the first criteria listed. With downgraded perspectives you can still toggle through the options but the number of tabs required differs between perspectives. Theoretically, you should be able to GUI script it with field names but that’s a bit beyond my skills.
EDIT: Argh, just tried this out of habit on a builtin perspective and, obviously, it doesn’t work. Going to fiddle around and see if I can add some code to determine if the perspective is custom or builtin and then act accordingly.
EDIT 2: This is so convoluted I almost want to delete this entire response and replace it with “umm, never mind”.
To determine if the perspective is custom or builtin:
if class of (selected sidebar tab of first document window of default document) is item or id of (selected sidebar tab of first document window of default document) contains "process" then
set perType to "builtin"
else
set perType to "custom"
end if
To force the correct number of fields to tab through in the View Options popover:
set search term of first document window of default document to ((search term of first document window of default document) & space)