Apologies if this questions has been answered before…I couldn’t find an answer!
I have started doing some automation of OmniFocus using AppleScript. Mostly focussed on modifying selected tasks.
I came cross Dan Byler’s scripts, which are great, and am tinkering with those. I was looking at this code:
set validSelectedItemsList to value of (selected trees where class of its value is not item and class of its value is not folder and class of its value is not context and class of its value is not perspective)
set totalItems to count of validSelectedItemsList
if totalItems is 0 then
set alertName to "Error"
set alertTitle to "Script failure"
set alertText to "No valid task(s) selected"
display dialog alertText
return
end if
…and started wondering about whether a primer / tutorial existed on the overall object model that OmniFocus uses in AppleScript? Something that explains how tasks relate to trees relate to items etc?
I can get the scripts to work…but I feel like I am not building any understanding!
Have you already discovered the reference material that you can access by double-clicking on OmniFocus in Script Editor’s Library window? For example, here’s the start of the documentation it provides for the task object:
taskn : A task. This might represent the root of a project, an action within a project or other action or an inbox item.
Totally agree that the reference material in the script dictionary isn’t the same as conceptual documentation, I just wanted to make sure that those resources were known.
Another resource that some people might not know about that comes with the app itself are the sample scripts which are embedded in the app: you’ll find those in OmniFocus.app/Contents/Resources/SampleScripts.
This has been a fascinating conversation so far…if there is any consideration being given to some kind of tutorial / resource to cover scripting in OmniFocus (a bit like the excellent Getting Started with OmniGraffle) then I’d like to +1 it!