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

 
Toggling a folder between On Hold and Active Thread Tools Search this Thread Display Modes
Discussion in another thread suggests that OmniFocus Ver 2 will allow us to set the status of a Folder to On Hold.

In the meanwhile, here is a draft applescript which toggles the contents and descendants of the selected folder between On Hold and Active (leaving the status of Completed and Dropped projects unchanged).

Code:
-- Ver 0.4
-- Toggles contents and descendants of the selected folder between ON HOLD and ACTIVE
-- The status of any COMPLETED and DROPPED projects is left unchanged
-- Any DROPPED subfolders are also left unchanged

tell application id "com.omnigroup.OmniFocus"
	tell front window
		set lstFolders to value of (selected trees of sidebar where class of value is folder)
		set refProjects to a reference to value of (selected trees of sidebar where ¬
			(class of value is project) and ((status of value is active) or (status of value is on hold)))
	end tell
	
	repeat with oFolder in lstFolders
		my ToggleFolderStatus(oFolder)
	end repeat
	
	set lstStatus to status of refProjects
	if length of lstStatus > 0 then
		if first item of lstStatus is active then
			set status of refProjects to on hold
		else
			set status of refProjects to active
		end if
	end if
end tell

on ToggleFolderStatus(oFolder)
	using terms from application "OmniFocus"
		set refProjects to a reference to (projects of oFolder where (status is active) or (status is on hold))
		set lstStatus to status of refProjects
		if length of lstStatus > 0 then
			if first item of lstStatus is active then
				set status of refProjects to on hold
			else
				set status of refProjects to active
			end if
		end if
		
		set lstFolders to folders of oFolder where hidden is false
		repeat with oSubFolder in lstFolders
			my ToggleFolderStatus(oSubFolder)
		end repeat
	end using terms from
end ToggleFolderStatus
--

Last edited by RobTrew; 2010-05-29 at 12:03 AM.. Reason: Allow for selecting and toggling more than one folder
 
If you are running OF 1.8, this toggling version is a little faster:

Code:
-- Ver 0.9 (OF 1.8 only)
-- Toggles status of contents and descendants of the selected folder(s) and project(s) between ON HOLD and ACTIVE

-- 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
	
	-- Find the first project in (or contained by) the selection
	set oProj to missing value
	set lstProjects to contents of refProjects
	if length of lstProjects > 0 then
		set oProj to first item of lstProjects
	else
		repeat with oFolder in lstFolders
			set lstProj to (flattened projects of oFolder where ((status is active) or (status is on hold)) and (hidden of its folder is false or its folder is missing value))
			if length of lstProj > 0 then
				set oProj to first item of lstProj
				exit repeat
			end if
		end repeat
	end if
	if oProj is missing value then return
	
	-- Determine the next toggle direction
	status of oProj
	if status of oProj is active then
		set eNewStatus to on hold
	else
		set eNewStatus to active
	end if
	
	-- and set the new status
	set status of refProjects to eNewStatus
	repeat with oFolder in lstFolders
		set (status of flattened projects of oFolder where ((status is active) or (status is on hold)) and (hidden of its folder is false)) to eNewStatus
	end repeat
end tell
--

Last edited by RobTrew; 2010-08-20 at 03:20 AM..
 
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Toggling Status of projects from active to on hold according to time of day smarsh OmniFocus Extras 6 2012-08-07 01:08 PM
Show active and on hold projects with script? mrubenson OmniFocus Extras 3 2012-01-04 11:01 AM
active/on hold/dropped status dloranz OmniFocus 1 for Mac 8 2011-06-22 02:48 PM
Folder 'On Hold' garoda OmniFocus 1 for Mac 9 2008-12-04 04:06 PM
Using 'Waiting' context set to 'On Hold' or 'Active' lilyblossom OmniFocus 1 for Mac 15 2008-08-09 08:34 PM


All times are GMT -8. The time now is 07:20 AM.


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