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

 
Defer (or 'snooze') tasks/projects Thread Tools Search this Thread Display Modes
feel free to use it if you like
 
Hello dbyler,
now it works. I forgot to create the application folder...
So now i got the defer icon in the toolbar.
Thank you very much for answering so fast.
Best Regards
Marc
 
I found a few bugs in the script, particularly with handling multiple selections. I also made deferral of both start and due dates the default. Here's the updated code:

Code:
(*
	This script takes the currently selected actions or projects and defers, or "snoozes", them by the user-specified number of days.
	The user may snooze just the due date or both the start and due dates (useful for skipping weekends for daily recurring tasks).
	
	version 0.1, by Dan Byler
	
	Copyright © 2008, Daniel N. Byler  (contact: dbyler@gmail.com)
	
	All rights reserved.
	
	Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
	
		• Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
		
		• Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
		
	THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
	
	version 0.1: Original release

	Installation: Copy to ~/Library/Scripts/Applications/Omnifocus
 	If desired, add to the OmniFocus toolbar using View > Customize Toolbar... within OmniFocus

	Known bugs:
		• When the script is invoked from the OmniFocus toolbar and canceled, OmniFocus returns an error. This issue does not occur when invoked from the script menu, a Quicksilver trigger, etc.

*)

property showAlert : true --if true, will display success/failure alerts
property useGrowl : true --if true, will use Growl for success/failure alerts
property defaultSnooze : 1 --number of days to defer by default

property alertItemNum : ""
property alertDayNum : ""
-- property successTot : 0
property growlAppName : "Dan's Scripts"
property allNotifications : {"General", "Error"}
property enabledNotifications : {"General", "Error"}
property iconApplication : "OmniFocus.app"


tell application "OmniFocus"
	tell front document
		tell (first document window whose index is 1)
			set theSelectedItems to selected trees of content
			set numItems to (count items of theSelectedItems)
			if numItems is 0 then
				set alertName to "Error"
				set alertTitle to "Script failure"
				set alertText to "No valid task(s) selected"
				my notify(alertName, alertTitle, alertText)
				return
			end if
			
			display dialog "Defer for how many days?" default answer defaultSnooze buttons {"Cancel", "OK"} default button 2
			(* if (the button returned of the result) is not "OK" then
				return
			end if  *)
			set snoozeLength to (the text returned of the result) as integer
			if snoozeLength is not 1 then
				set alertDayNum to "s"
			end if
			set changeScopeQuery to display dialog "Modify start and due dates?" buttons {"Cancel", "Due Only", "Start and Due"} default button 3 with icon caution giving up after 60
			set changeScope to button returned of changeScopeQuery
			if changeScope is "Cancel" then
				return
			else if changeScope is "Start and Due" then
				set modifyStartDate to true
			else if changeScope is "Due Only" then
				set modifyStartDate to false
			end if
			set selectNum to numItems
			set successTot to 0
			repeat while selectNum > 0
				set selectedItem to value of item selectNum of theSelectedItems
				set succeeded to my defer(selectedItem, snoozeLength, modifyStartDate)
				if succeeded then set successTot to successTot + 1
				set selectNum to selectNum - 1
			end repeat
			set alertName to "General"
			set alertTitle to "Script complete"
			if successTot > 1 then set alertItemNum to "s"
			set alertText to successTot & " item" & alertItemNum & " deferred " & snoozeLength & " day" & alertDayNum & ". (" & changeScope & ")" as string
		end tell
	end tell
	my notify(alertName, alertTitle, alertText)
end tell

on defer(selectedItem, snoozeLength, modifyStartDate)
	set success to false
	tell application "OmniFocus"
		set theDueDate to due date of selectedItem
		if (theDueDate is not missing value) then
			set newDue to (theDueDate + (86400 * snoozeLength))
			set due date of selectedItem to newDue
			set success to true
		end if
		if modifyStartDate is true then
			set theStartDate to start date of selectedItem
			if (theStartDate is not missing value) then
				set newStart to (theStartDate + (86400 * snoozeLength))
				set start date of selectedItem to newStart
				set success to true
			end if
		end if
	end tell
	return success
end defer


on notify(alertName, alertTitle, alertText)
	if showAlert is false then
		return
	else if useGrowl is true then
		tell application "GrowlHelperApp"
			register as application growlAppName all notifications allNotifications default notifications enabledNotifications icon of application iconApplication
			notify with name alertName title alertTitle application name growlAppName description alertText
		end tell
	else
		display dialog alertText with icon 1
	end if
end notify
__________________
Cheers,

Curt
 
Hi

I'm trying to add this script to the toolbar, with no luck. I've put it in

~/Library/Scripts/OmniFocus

which I believe is the right place, and it show up in the apple scripts menu on the RH side of the menu bar, but I can't work out how to drag and drop it onto the toolbar. It doesn't appear on the toolbar customization palette, and it won't drop anywhere.

I'm sure I'm doing something obviously stupid/wrong, but I can't work out what it is. Could anyone help, please?

(I'm running OF 1.5, latest RC).

thanks
FB
 
Quote:
Originally Posted by fozziebear View Post
I'm trying to add this script to the toolbar, with no luck. I've put it in

~/Library/Scripts/OmniFocus

which I believe is the right place, and it show up in the apple scripts menu on the RH side of the menu bar, but I can't work out how to drag and drop it onto the toolbar. It doesn't appear on the toolbar customization palette, and it won't drop anywhere.
Place the script in ~/Library/Scripts/Applications/OmniFocus. It should then appear as an option for the toolbar customization.
 
Quote:
Originally Posted by curt.clifton View Post
I found a few bugs in the script, particularly with handling multiple selections. I also made deferral of both start and due dates the default. Here's the updated code:
This is fantastic, and I use it all the time. Thanks!

It also works with negative numbers of days, if you want to do something sooner.
 
Curt, thanks for your bug fixes—I was having trouble with a couple of them. Those changes and a few others are incorporated in a new version...

Release notes & download here
 
Thanks for the update on this script. I'll add that that one thing that I would like to see in this is the option to modify start only, due only, or start and due. I tried modifying this script a while back to see if I could do it, but I'm not script-savvy enough to make it work. One limitation that I ran into right away is that apparently one cannot have 4 buttons in a script dialog, so if there are options to modify start, due, both, then there cannot be a cancel button.
 
Greg,

Good idea. I thought about wrapping "Start only" into the Defer script but decided it's conceptually different enough to "snooze" an item (leaving the due date intact) than to "defer" it (pushing the whole item back)... so I adapted this into a new "Snooze" script that does what you want.

More info & download here.
 
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Applescripts: Better Templates, Complete Tasks From Mail.app Sender, and Batch-Defer pxldot OmniFocus Extras 25 2014-04-01 06:55 AM
Is it possible to see Defer and Due dates at the project level? jelmore OmniFocus 2 for Mac (Private Test) 1 2013-04-30 12:00 PM
repeating projects/tasks when all tasks/subtasks are complete? djc225 OmniFocus 1 for Mac 1 2012-03-20 06:55 PM
Snooze (not "defer") tasks/projects dbyler OmniFocus Extras 0 2009-02-26 06:59 PM
Snooze button Mitch Wagner OmniFocus 1 for Mac 8 2009-02-21 05:29 AM


All times are GMT -8. The time now is 08:16 PM.


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