All in all, OF2 does some nice things with managing dates, like “deferred with container.” However, I haven’t yet found an automatic way to keep project dates in line with their action dates. This is probably good, as there are situations where one wouldn’t want that. On the other hand, I usually enter defer and due dates are part of entering actions (sort of bottom up), rather than entering them in a project and then wanting them to trickle down onto actions.
This leaves situations where a project is marked as due before the due date of its latest action (either I’m unnecessarily panicked or something isn’t going to be done on time), a project is showing up as active even though all of its actions have defer dates after today (I shouldn’t be seeing it), etc. The first script below checks all selected projects to make sure they have due and deferred dates and that these are consistent with the dates of contained actions. The second script fixes the project’s due and deferred dates to the latest and earliest dates, respectively, of contained actions. That’s normally what I want.
There is no guarantee that these scripts won’t destroy your date, make your cat bald, etc., so you use them at your own risk. In particular, I don’t use sub-projects, so I have no idea how they will interact with task lists that do. Also, I have the Satimage scripting addition from http://www.satimage.fr and portions of this code rely on it. There are significant infelicities in this code, but since I wrote it for my own use, I haven’t taken the time to clean then up.
(*******
Check project dates.scpt
Checks all selected projects to make sure they have due and deferred dates and that these are consistent with the dates of contained actions.
Requires the Satimage osax <http://www.satimage.fr>
Glenn Hoetker, ghoetker@me.com, 2014.
USE AT YOUR OWN RISK.
*******)
use OmniFocus : application "OmniFocus"
use TextEdit : application "TextEdit"
use scripting additions
set problemProjects to {}
set selectedProjects to value of selected trees of content of first document window of front document of OmniFocus
repeat with eachProject in selectedProjects
if class of eachProject is project and singleton action holder of eachProject is false then
try
set projectsDeferDate to defer date of eachProject
set earliestDeferDate to defer date of (every task of eachProject whose completed is false)
set earliestDeferDate to item 1 of (sortlist (dates of earliestDeferDate) with ascending)
if projectsDeferDate is missing value then copy {projectName:name of eachProject, problem:"No defer date"} to end of problemProjects
if projectsDeferDate > earliestDeferDate then copy {projectName:name of eachProject, problem:"Project deferred until after earliest action"} to end of problemProjects
if projectsDeferDate > earliestDeferDate then copy "Project deferred until after earliest action" to end of item 2 of projectName of projectProblems
end try
try
set projectsDueDate to due date of eachProject
set latestDueDate to due date of (every task of eachProject whose completed is false)
set latestDueDate to item 1 of (sortlist (dates of latestDueDate) with ascending)
if projectsDueDate is missing value then copy {projectName:name of eachProject, problem:"No due date"} to end of problemProjects
if projectsDueDate < latestDueDate then copy {projectName:name of eachProject, problem:"Project due before latest action"} to end of problemProjects
end try
end if
end repeat
set resultText to ""
set oldProjectName to ""
repeat with theProject in problemProjects
if theProject's projectName is not equal to oldProjectName then set resultText to resultText & theProject's projectName & return & return
set resultText to resultText & tab & theProject's problem & return & return
set oldProjectName to theProject's projectName
end repeat
tell TextEdit
activate
set theNewDoc to make new document
set theNewDoc's text to resultText as text
set theNewDoc's name to "Problem Projects"
end tell
-- display dialog resultText buttons {"Cancel"} default button 1 with title "Problem Projects"
The second script:
(*******
Fix project dates.scpt
For selected projects, sets the project's due and deferred dates to the latest and earliest dates, respectively, of contained actions.
Requires the Satimage osax <http://www.satimage.fr>
Glenn Hoetker, ghoetker@me.com, 2014.
USE AT YOUR OWN RISK.
*******)
use OmniFocus : application "OmniFocus"
use scripting additions
set selectedProjects to value of selected trees of content of first document window of front document of OmniFocus
repeat with eachProject in selectedProjects
if class of eachProject is project then
try
set earliestDeferDate to defer date of (every task of eachProject whose completed is false)
set earliestDeferDate to item 1 of (sortlist (dates of earliestDeferDate) with ascending)
set defer date of eachProject to earliestDeferDate
end try
try
set latestDueDate to due date of (every task of eachProject whose completed is false)
set latestDueDate to item 1 of (sortlist (dates of latestDueDate) without ascending)
set due date of eachProject to latestDueDate
end try
end if
end repeat