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 1 for Mac
FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
Script to make mutiple copies of a task in a "review" action list with different start dates Thread Tools Search this Thread Display Modes
Hi,
Spent the past 2 weeks setting up Omnifocus to work for me, and the results are already showing. One script I would love, would be to take something from my Reading List, and make copies in a Review single-action list with predefined start dates.
Eg. Finish reading a book(or a reading for uni) and have my evernote notes linked to it. Then run the script, which makes 5 copies of the task in a "Review" single-action list with the start dates 3 days from now, 3 weeks, 3m, 1yr, 2yr.

I've made some simple applescripts before, but never one for omnifocus. Can anyone give me some pointers? Really just need to know how to refer to the currently highlighted task, and how to create a new task in a defined action list. I should be able to set properties (start dates)

Any guidance would be much appreciated

James
 
Here's a rough starting point. Put as many comma-separated values in the pReviewIntervals list as you like; those are the numbers of days until each copy of the source action(s) is added to the project specified in the pReviewProject property. By default, you get 2 days from the start date to the due date, but that can be configured in 24 hour increments. The script now uses the default due time setting from OmniFocus.

This has gotten the amount of testing you might expect from the compensation package we agreed upon :-)

If you need help installing this, see RobTrew's excellent FAQ. Thanks also to RobTrew for enlightening me on how to elicit the default due time from OmniFocus.

Code:
-- Ebbinghaus review scheduler
-- schedules tasks for reviewing learned material in spirit of Ebbinghaus forgetting curves
-- Bill Palmer, February 2013

property pReviewProject : "Review" -- name of project which will receive tasks
property pReviewIntervals : {3, 3 * 7, 3 * 30, 365, 2 * 365} -- number of days before each repeat, augment as desired
property pReviewDaysUntilDue : 2 -- allow two days after start date for completion
property pAutoSave : false -- set this to false for faster performance but slightly more risk

on GetDefaultDueTime()
	tell application id "OFOC" to tell front document to set timeStr to value of setting id "DefaultDueTime"
	set {otid, text item delimiters} to {text item delimiters, ":"}
	set {dueHour, dueMin, dueSec, text item delimiters} to every text item in timeStr & otid
	return (((dueHour * 60) + dueMin) * 60 + dueSec)
end GetDefaultDueTime

on ProcessAction(selAction, dstProject, dateToday, dueTimeOffset)
	local startDate, dueDate, i
	tell application id "OFOC"
		repeat with i from 1 to (length of pReviewIntervals)
			set newAction to duplicate selAction to end of tasks of dstProject
			set startDate to dateToday + (item i of pReviewIntervals) * days
			set dueDate to startDate + pReviewDaysUntilDue * days + dueTimeOffset
			tell newAction to set {start date, due date, completed} to {startDate, dueDate, false} -- if user already completed original, we need to make duplicate active
		end repeat
	end tell
end ProcessAction

on run {}
	set dateToday to (current date) - (time of (current date))
	set dueTime to my GetDefaultDueTime()
	tell application id "OFOC"
		tell front document
			tell content of first document window
				set lstSelected to value of (selected trees where class of its value is task)
				if ((count of lstSelected) = 0) then
					display alert "No suitable tasks in selection"
					return
				end if
			end tell
			try
				set dstProject to first flattened project whose name is pReviewProject
			on error
				display alert "Could not find destination project \"" & ¬
					pReviewProject & "\""
				return
			end try
			set oldWillAutosave to will autosave
			set will autosave to pAutoSave
			try -- catch any errors and restore autosave setting
				repeat with thisOne in lstSelected
					my ProcessAction(thisOne, dstProject, dateToday, dueTime)
				end repeat
			end try
			set will autosave to oldWillAutosave
		end tell
	end tell
end run

Last edited by whpalmer4; 2013-02-17 at 11:48 PM..
 
Thanks so much, you're amazing!! Made two copies, one for general material to review over that schedule, and one for university work, with a much more frequent schedule.
Do you mind if I share this thread? I got the idea for this review schedule from the Omnifocus posts at Asian Efficiency, and I know that they will make great use of this. Perhaps even share it on their blog.
Up to you though. Thanks again :)
 
I've updated the script to use the default due time setting from OmniFocus. As for sharing it, I can hardly expect to claim it as an precious secret, not to be divulged, having posted it on the Omni forum! Thanks for asking, however. Feel free to point anyone who might find it useful at the thread.
 
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Repeating actions daily at same hour [A: set both Start & Due dates, choose "repeat every"] Surefoot3 OmniFocus for iPad 4 2012-11-05 11:56 AM
How can I sync Start/Due dates to iCal? [A: use "export calendar" instead.] filmgeek iCal Sync 10 2011-12-03 06:31 PM
Can you make an action "parallel" in a project that is serial? tlester OmniFocus 1 for Mac 1 2008-10-13 08:34 AM
Action status: "next action" and start dates dondo OmniFocus 1 for Mac 3 2008-08-06 09:48 PM
Cognitive load of parsing "start" & "end" dates kasi OmniFocus 1 for Mac 5 2008-05-15 04:22 PM


All times are GMT -8. The time now is 05:32 PM.


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