I’m programming OmniFocus in Objective-C using the Scripting Bridge. I’d like to know two things:
How do I query all available tasks? This could be by filtering the document’s flattenedTasks with a predicate, but I don’t know what predicate to use.
For any given task (i.e. I already have a Task object), how can I tell whether it is available? Do I have to do the logic (check for defer date, context on hold, project on hold etc) myself?
Hearing how you do those things in pure AppleScript may be helpful, so any AppleScript gurus are also welcome to reply!
-- Unflag every available task in every context (it has to be assigned a context)
tell application "OmniFocus"
tell default document
set flagged of (every available task of every flattened context whose flagged is true) to false
end tell
end tell
Does this actually work? I’m getting an AppleScript error. I can do this for every flattened context, but that’s no use if I want to get the tasks that have no context.
Arg! You’re right. It won’t work. According to the AppleScript dictionary, Contexts can have Available Tasks, but Projects don’t. I’ll create a feature request in our bug system to see if we can bring this over to projects.
Without access to the ‘available tasks’, you’d have to do the availability logic yourself, which seems rather like re-inventing the wheel. I’ll make sure that feature request is filed too.