The OmniFocus AppleScript Object Model

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
 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!

Short Answer: No.

Longer Answer: None that I’ve ever discovered. I’ve had to puzzle through a lot based on what already existed.

Exactly. Perhaps someone with greater insight can point to a place of greater enlightenment.


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:

task n : A task. This might represent the root of a project, an action within a project or other action or an inbox item.

   contains tasks, flattened tasks; contained by documents, contexts, tasks.
  id (text) : The identifier of the task.
  name (text) : The name of the task.
  note (rich text) : The note of the task.
  container (document, quick entry tree, project, or task, r/o) : The containing task, project or document.

A script dictionary only goes so far. It does not give any examples to learn how the pieces can be fit to work effectively.


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

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!

OK…so I decided to have a go at starting to explain what is going on…

Mostly as reminder for me…but hopefully helpful to others too.

Thoughts and feedback welcome!