View Single Post
Quote:
Originally Posted by Brian View Post
The ability to set a folder to "On Hold" instead of dropping it should be coming in version 2; that sounds like it'll do what you're looking for.
In the meanwhile, the status of all projects in the selected folder (and any sub-folders which it may have) can be set to On Hold (or back to Active), with the applescript below.

(the status of any Completed or Dropped projects is left unchanged)

Code:
-- Ver 0.8
-- Sets status of contents and descendants of the selected folder(s) and project(s) to ON HOLD or ACTIVE
-- (depending on user response to a prompt)
-- The status of any COMPLETED and DROPPED projects is left unchanged
-- Any DROPPED subfolders are also left unchanged

property pActive : "Active"
property pOnHold : "On Hold"

tell application id "com.omnigroup.OmniFocus"
	tell front window
		set oPanel to sidebar
		if (count of selected trees of oPanel) < 1 then
			set oPanel to content
			set lstFolders to {}
		else
			set lstFolders to value of (selected trees of oPanel where ¬
				(class of value is folder) and (hidden of value is false))
		end if
		set refProjects to a reference to value of (selected trees of oPanel where ¬
			(class of value is project) and ((status of value is active) or (status of value is on hold)))
	end tell
	
	set varChoice to choose from list {pActive, pOnHold} with prompt "Set selection & descendants to:"
	if varChoice is not false then
		if first item of varChoice is pActive then
			set eNewStatus to active
		else
			set eNewStatus to on hold
		end if
		
		set status of refProjects to eNewStatus
		repeat with oFolder in lstFolders
			my SetFolderStatus(oFolder, eNewStatus)
		end repeat
	end if
end tell

on SetFolderStatus(oFolder, eNewStatus)
	using terms from application "OmniFocus"
		set refProjects to a reference to (projects of oFolder where ((status is active) or (status is on hold)))
		set status of refProjects to eNewStatus
		
		set lstFolders to folders of oFolder where hidden is false
		repeat with oSubFolder in lstFolders
			my SetFolderStatus(oSubFolder, eNewStatus)
		end repeat
	end using terms from
end SetFolderStatus
--

Last edited by RobTrew; 2010-05-29 at 09:51 PM.. Reason: Logic moved to where statements (faster)