The Omni Group Forums

The Omni Group Forums (http://forums.omnigroup.com/index.php)
-   OmniFocus Extras (http://forums.omnigroup.com/forumdisplay.php?f=44)
-   -   Applescript help: get every project (http://forums.omnigroup.com/showthread.php?t=4668)

Lutin 2007-08-27 09:05 AM

Applescript help: get every project
 
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

[QUOTE=Lutin;20075]
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.
[/QUOTE]

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 [URL="http://www.rose-hulman.edu/~clifton/software.html#VerifyNA"]here[/URL].

RobTrew 2007-08-29 04:12 AM

You could get a list of project objects with code something like this:

[CODE]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[/CODE]

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:

[CODE]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
[/CODE]


All times are GMT -8. The time now is 02:49 PM.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2024, vBulletin Solutions, Inc.