Hare-brained idea for a 'Deferred' perspective (Applescript help needed)

For my OmniFocus layout, I try to mimic the ‘Things’ app’s layout somewhat. I have five perspectives that constitute my main layout, and then dozens of others below them. But, I reign in my system’s complexity by having a simple layout in keeping with conventional wisdom.
These consist of my:
Inbox - Pretty self explanatory, the built-in perspective
Today - Flagged tasks OR due soon tasks (could use the built-in Flagged perspective if you prefer)
Next - All available tasks from projects, excluding certain contexts that are saved for other specific uses; all the things I can do in my normal environments
Deferred - Any tasks that will appear in the ‘Next’ perspective at a future point in time*
Someday - The contents of my Someday/Maybe list project (or, alternatively, anything currently set to ‘On Hold,’ though again excluding certain contexts)

This works pretty well, and lets me leverage both the elegant simplicity of something like Things with the powerful complexity OmniFocus provides. The problem is with the Deferred perspective. What I described above is how I would like for this perspective to function. However, the closest OmniFocus will let me come to this is to show me all Remaining tasks, grouped and sorted by Defer Date. This leaves me with a behemoth of tasks, many of which have a Defer date in the past, making them either currently available tasks or tasks that were formally deferred to a date in the past and are yet blocked by a sequential task dependency. On the Mac and iPad, this perspective can still be somewhat useful, as I can quickly collapse the groupings up until I get to the “Tomorrow” and beyond groupings. Then, I can view tasks that are deferred to sometime in the future.

You’re probably wondering why I do not just use the built-in Forecast perspective. Well, as it is, I do not want to see tasks that are due on the day I’m looking at, just those that have been deferred to then. Also, the Forecast perspective does not allow me to exclude certain contexts or projects, leaving me with a hopelessly confused mess of items from groceries to long sequential projects that appear on the same day, etc.

What I would really like to be able to do is modify my existing Deferred perspective to be able to exclude anything with a Defer date in the past. (Another nice thing, for both this and the Forecast perspective, would be to only show me the “First Remaining” task, similar to the ‘First Available’ task but for yet-unavailable sequential projects. For example, my massive sequential ‘Weekly Review’ project could simply show up as the first task, not all fifty million items within.) A thought occurred to me that this could perhaps theoretically be mended by Applescript. Would it not be possible to, say on a daily basis, run a script that would find tasks that have a defer date after the current date/time and append the Note field of the task with a keyword like “DEFERFUTURE.” (We would set our Deferred perspective to “find text: DEFERFUTURE.”)
At this point, the script would be very useful and helpful already. However, to take this to its ultimate conclusion, it could then find tasks which contain “DEFERFUTURE” whose defer dates are earlier than the current date/time and remove the keyword from their Notes fields. However, even if this were not part of the script, it would already cut down greatly on the unwanted inclusions of things in my Deferred perspective.

I know nothing about how to script on the Mac, so I leave this as an idea in case anyone with the knowhow would find it useful and care to implement it for themselves and share it.

The latter issue can be cleared by setting the Perspective to show First Available.

I am a bit confused. I think what you want is to see a list of only those (first available) tasks that are deferred to a future date. Yes, this could be implemented with some AppleScript tricks. But, would it really be worth the time versus the administrative hassle? I’d have to ponder a bit more.

My immediate thought is this is better to do once multiple tags are implemented. An AppleScript would search tasks whose defer date > today and TAG them in a special way (e.g. “Pending for Future”). In the meantime, by comparison, the method to add notes and remove notes and find notes is fraught with complications.

I suggest that you might otherwise try an approach that is immediate to implement. First, eliminate the problem of seeing all available tasks by showing only those that are First Available. Then, Group by Defer Date. You can collapse those dates that are of no interest to you.


Thanks for taking the time and mental engagaement to respond.
I agree that using the upcoming “tagging” feature would be a cleaner approach.
However, I think you misunderstand my Deferred perspective. If I select “First Available,” I no longer see tasks deferred to the future, which is specifically what I do want to see there.

Duh. Of course.

Here’s an AppleScript to put a note in the note field of tasks whose deferred date is greater than today. The inverse problem is left as an exercise for the reader. :-)

property pNotetoAdd : "Future Deferred"

on run
set cDate to current date
tell application "OmniFocus" to tell default document
	set theList to the id of every flattened task whose (defer date > cDate)
	if theList is {} then return
	repeat with taskID in theList
		set itsNote to (pNotetoAdd & return & the note of task id taskID)
		set the note of task id taskID to itsNote
	end repeat
end tell
end run


1 Like

That’s brilliant! Thanks very much for that.

If you don’t mind a suggestion, though, could it be made to skip over tasks that already contain the ‘note to add’ property? As it is, tasks stand to have the same note prepended to the Note field each time the script is run. And the “flattened task” descriptor is a godsend for this!

It could probably be done by something to the effect of

if (the note of task id taskID does not contains pNotetoAdd) then
   process it
 end if

The exact syntax to confirm the content of the note field may be slightly different.

Ultimately, the fact that this can generate multiple lines of pNotetoAdd … is it really that much of a headache? Eventually, the note text will be cleared manually or the task will be completed.

This of course suggests that a further addition would be to clear the previously existing notes before processing the new notes. And then we end up going down the rabbit hole of continuously cluttered code. I’d rather wait for multiple tags and code this one up clean.


I agree with you. The “if” language seems to be working though, so if I have the script set to run automatically several times a day, it won’t leave me with dozens of the same thing in a note field. At my weekly review, I have a reminder to go into the Deferred perspective and manually clear out the prepended tag from any tasks that aren’t future anymore.
It’s a little eccentric, but it will suit my needs very nicely. Thanks again for the assistance! Once we can tag tasks, it’ll be a nicer way to accomplish this same thing.

Go to the perspective and then run something like this …

set theList to the id of every flattened task
repeat with taskID in theList
     set the note of task id taskID to ""
end repeat

Prepend a call to preset the Perspective appropriately and you will generate an AppleScript to run routinely to clear the notes for you.


Only problem with that is it seems like it would erase the note field altogether, along with whatever contents it may hold. I tried mucking around with the first script you provided but was unable to find a way inside the “tell OmniFocus” to find the tag and replace with nothing (or a space or something).
Manually deleting a line from a dozen or so notes once a week is an okay price to pay for having a functional Deferred perspective! :)

The issues that you mention are why I defer to others who have the need to take this further. The code becomes too cluttered for my liking.

Once multiple tags are in practice the approach becomes so much more direct.


Agreed; I’m thrilled to manually manage no-longer-deferred-to-the-future items in the meantime. Thanks again for your intervention.