The Omni Group
These forums are now read-only. Please visit our new forums to participate in discussion. A new account will be required to post in the new forums. For more info on the switch, see this post. Thank you!

Go Back   The Omni Group Forums > OmniFocus > OmniFocus Extras
FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
Applescript help: get every project Thread Tools Search this Thread Display Modes
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,
 
Quote:
Originally Posted by Lutin View Post
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.
__________________
Cheers,

Curt
 
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
 
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.
 
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
 
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Applescript request - Jump to Project gcrump OmniFocus Extras 30 2010-06-07 10:48 PM
Applescript -- Move project or action to: ??? darrenburgess OmniFocus 1 for Mac 1 2010-01-18 07:05 AM
Auto Project Sort with AppleScript urtlnomis OmniFocus 1 for Mac 0 2009-02-18 12:00 PM
Applescript OmniFocus to focus on one project Lutin OmniFocus Extras 4 2007-09-20 02:52 AM
'Completed' project - GUI vs. Applescript RobTrew OmniFocus 1 for Mac 1 2007-06-25 08:38 PM


All times are GMT -8. The time now is 04:44 AM.


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