Guest
2010-06-01, 12:02 AM
In case anyone looks to this thread for a solution, a couple of updates come to mind.
My current summary of the faster where-query approach might have the form:
Code:
tell application "OmniFocus"
set oDoc to default document
set lstProjects to my ProjectList(oDoc)
-- set focus of front document window of oDoc to lstProjects
end tell
on ProjectList(oParent)
using terms from application "OmniFocus"
tell oParent
-- ADJUST THE WHERE QUERIES TO MATCH THE PURPOSE
set lstProjects to projects where (status is active) or (status is on hold)
set lstFolders to folders where hidden is false
end tell
repeat with oFolder in lstFolders
set lstProjects to lstProjects & my ProjectList(oFolder)
end repeat
return lstProjects
end using terms from
end ProjectList
While the non-recursive (but slower) approach based on named filters can be speeded up a little by getting a value list from a reference, to avoid iteration.
Code:
-- AVAILABLE FILTERS:
-- "all-projects"
-- "remaining-projects"
-- "active-projects"
-- "stalled-projects"
-- "pending-projects"
-- "on-hold-projects"
-- "dropped-projects"
-- "completed-projects"
property pFilter : "all-projects"
property pProject : "project"
property pAny : "any"
property pNone : "none"
property pAll : "all"
set lstProjects to ProjectList(pFilter)
on ProjectList(strFilter)
tell application id "com.omnigroup.OmniFocus"
tell default document
tell (make new document window)
set selected view mode identifier to pProject
set focus to {}
tell content
set selected grouping identifier to pNone
set selected sorting identifier to pNone
set selected task duration filter identifier to pAny
set selected task flagged filter identifier to pAll
set selected task state filter identifier to pAll
end tell
tell sidebar
select library
set selected smart group identifier to strFilter
end tell
-- value list from a reference (avoids iteration)
set lstProject to value of trees of content
close
end tell
end tell
end tell
lstProject
end ProjectList
--
Last edited by RobTrew; 2010-06-01 at 01:24 AM..