View Full Version : Applescript help: get every project
Lutin
2007-08-27, 09:05 AM
Hi,
I'm having some difficulties to get a list of all active projects, no matter what filter, focus or anything else is enabled.
Could you point me in the right direction.
Thank you,
curt.clifton
2007-08-27, 11:38 AM
I'm having some difficulties to get a list of all active projects, no matter what filter, focus or anything else is enabled.
Could you point me in the right direction.
The last time I checked there was no simple way to get all projects, including those inside folders. You can get to them all, but it requires walking the tree of folders and projects. My Verify Next Actions Exist script includes recursive code for doing this. The script is available here (http://www.rose-hulman.edu/~clifton/software.html#VerifyNA).
RobTrew
2007-08-29, 04:12 AM
You could get a list of project objects with code something like this:
on run
tell application "OmniFocus"
set lstSections to every section of first document
set lstProjects to my ListProjects(lstSections, {})
end tell
display dialog length of lstProjects
end run
on ListProjects(lstSections, lstProjects)
using terms from application "OmniFocus"
repeat with oSectn in lstSections
if class of oSectn is project then
-- append to project list
set end of lstProjects to oSectn
else
-- expand existing project list with any contents of this folder
set lstSubSections to every section of oSectn
if lstSubSections ≠ {} then
set lstProjects to my ListProjects(lstSubSections, lstProjects)
end if
end if
end repeat
end using terms from
return lstProjects
end ListProjects
Lutin
2007-08-29, 05:35 AM
Curt, I had seen your code, and was hoping that something more direct had been added to OmniFocus dictionary.
Thank to both of you for the reply.
RobTrew
2007-08-29, 10:30 AM
On reflection, the following might be a little simpler:
on run
tell application "OmniFocus"
set lstSections to every section of first document
set lstProjects to my ListProjects(lstSections)
end tell
display dialog length of lstProjects
end run
on ListProjects(lstSections)
set lstProjects to {}
using terms from application "OmniFocus"
repeat with oSectn in lstSections
if class of oSectn is project then
set end of lstProjects to oSectn
else
set lstSubSections to every section of oSectn
if lstSubSections ≠ {} then
set lstProjects to lstProjects & my ListProjects(lstSubSections)
end if
end if
end repeat
end using terms from
return lstProjects
end ListProjects
vBulletin® v3.8.7, Copyright ©2000-2024, vBulletin Solutions, Inc.