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

 
routine to process inbox items Thread Tools Search this Thread Display Modes
Hi every body,
I've been playing around Omnifocus for a while now, reading and reading again
GTD book and even listening to the 8 (nearly 9) Hours of GTD Live 2 times.
And I got to the conclusion that i will not get GTD unless i was forced to ask me the questions David Allen is asking each time he is processing something.... (you know the kind of martial discipline unless you cannot apply GTD in the right way ;))

the fruit of this reflexions is a script that process my inbox items (those i've selected) and it asks the following questions :

what is the outcome of this item? (get the answer in the task's note)
is it actionnable? (yes or no) if no you've got the choice trash or someday/Maybe) trash delete the task; someday/maybe transform the task into a project in my folder "someday/maybe Projects" folder

does it require more than 1 action?-if yes it creates a project with the outcome as note in a folder named "to mindmap" (i use Xmind to "natural plan" my project and then use the excellent script here to transcript it in omnifocus)
-if no it asks the questions
does it take more than 2 min? )> yes pops up a do it! display dialog
if no
it asks which existing project you want to assign the item
then
are you the right person to do it ?
(if no it assign the task to context "waiting")
if yes then it ask which context is required to do the task
and then it ask if it is time specific (if yes it tags the task "time specific" to get it in a specific perspective)
and off course it ask how much time i need to do the task (if the answer is 180 the script propose to transform my task into project as over 2hours I can't get fully involved in only one task :p)

my script is not perfect => too much time when loading the data from onmifocus (especially when it creates the list )
i you can help me to optimize my script if you find it helps to get "GTD" diciplined

Best regards (and awaiting a lot of critics....):rolleyes:
Code:
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"
property action : false
property projet : false
property theContextname : "@Home"
global contextnameList
global projectnameList
global projectidList
global contextidlist
--chargement des contexts dans contextnameList
tell application "OmniFocus"
	set contextnameList to {}
	set contextidlist to {}
	
	set contextnameList to my onContexts(contexts of default document)
	set contextidlist to my onidcontexts(contexts of default document)
end tell

on onContexts(contextList)
	repeat with aContext in contextList
		my onContext(aContext)
	end repeat
	return contextnameList
end onContexts

on onidcontexts(contextList)
	repeat with aContext in contextList
		my onidContext(aContext)
	end repeat
	return contextidlist
end onidcontexts

on onContext(aContext)
	using terms from application "OmniFocus"
		set contextName to name of aContext
		set contextLocation to location of aContext
		set contextnameList to contextnameList & contextName
		my onContexts(contexts of aContext)
	end using terms from
end onContext

on onidContext(aContext)
	using terms from application "OmniFocus"
		set contextid to id of aContext
		set contextidlist to contextidlist & contextid
		my onidcontexts(contexts of aContext)
	end using terms from
end onidContext
--fin du chargement

--chargement des Projects dans projectnameList
set projectnameList to {}
set projectidList to {}

tell application "OmniFocus"
	set lstSections to every section of first document
	
	set projectnameList to my ListSections(lstSections, projectnameList, 0)
	set projectidList to my TrueListSections(lstSections, projectidList, 0)
end tell

on ListSections(lstSections, strList, intDepth)
	using terms from application "OmniFocus"
		repeat with oSectn in lstSections
			if class of oSectn is project then
				
				-- PROJECT
				if oSectn is not completed and status of oSectn is not dropped and status of oSectn is not on hold then
					set decalage to ""
					repeat intDepth times
						set strList to strList
						set decalage to decalage & tab
					end repeat
					
					set namelist to decalage & name of oSectn
					set strList to strList & namelist
					
				end if
			else
				-- FOLDER
				if oSectn is not hidden then
					set decalage to ""
					repeat intDepth times
						set strList to strList
						
						set decalage to decalage & tab
					end repeat
					
					set namelist to decalage & "folder" & name of oSectn
					set strList to strList & namelist
					
					-- ANY CONTENTS OF FOLDER			
					set lstSubSections to every section of oSectn
					if lstSubSections ≠ {} then
						set strList to my ListSections(lstSubSections, strList, intDepth + 1)
					end if
				end if
			end if
		end repeat
	end using terms from
	
	return strList
end ListSections

on TrueListSections(lstSections, strList, intDepth)
	using terms from application "OmniFocus"
		repeat with oSectn in lstSections
			if class of oSectn is project then
				
				-- PROJECT
				if oSectn is not completed and status of oSectn is not dropped and status of oSectn is not on hold then
					set decalage to ""
					repeat intDepth times
						set strList to strList
					end repeat
					set idlist to id of oSectn
					set strList to strList & idlist
					
				end if
			else
				-- FOLDER
				if oSectn is not hidden then
					repeat intDepth times
						set strList to strList
					end repeat
					
					set idlist to id of oSectn
					set strList to strList & idlist
					
					-- ANY CONTENTS OF FOLDER			
					set lstSubSections to every section of oSectn
					if lstSubSections ≠ {} then
						set strList to my TrueListSections(lstSubSections, strList, intDepth + 1)
					end if
				end if
			end if
		end repeat
	end using terms from
	
	return strList
end TrueListSections
--fin du chargement

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
			set selectNum to numItems
			repeat while selectNum > 0
				set Selectedtask to value of item selectNum of theSelectedItems
				my Process(Selectedtask)
				
				set selectNum to selectNum - 1
			end repeat
		end tell
	end tell
end tell



on Process(Selectedtask)
	--recuperation des infos de la tache 
	tell application "OmniFocus"
		set taskName to name of Selectedtask
		set taskNote to note of Selectedtask as rich text
	end tell
	--end recuperation des infos de la tache
	
	--add outcome to the task
	set question1 to display dialog taskName & return & "what is the outcome?" & return & "(ie describe the finished state)" default answer "" buttons {"OK", "Cancel"} default button 1
	set outcome to (the text returned of the result) as text
	if outcome is not "" then
		tell application "OmniFocus"
			set note of Selectedtask to taskNote & return & outcome
		end tell
	end if
	--end of addition
	
	-- set if it is actionnable or not
	set question2 to display dialog "is it actionnable?" buttons {"yes", "no"} default button 1
	set answer2 to button returned of question2
	if answer2 is "yes" then
		--set if it is a project
		set question3 to display dialog "does it require more than 1 action?" buttons {"yes", "no"} default button 2
		set answer3 to button returned of question3
		if answer3 is "yes" then
			my project(Selectedtask, "To mindmap")
			-- end of the loop if it is a project
		else
			--set if it takes more than 2 min
			set question4 to display dialog "will it take more than 2 minutes?" buttons {"yes", "no"} default button 1
			set answer4 to button returned of question4
			if answer4 is "no" then
				set timer to display dialog "Do It!" buttons {"OK"} with icon caution giving up after 120
				set overtime to gave up of timer
				if overtime is equal to true then
					set timer2 to display dialog "your 2 minutes are over click once you've finished your task" buttons {"OK"}
				end if
				tell application "OmniFocus"
					tell front document
						set completed of Selectedtask to true
						set estimated minutes of Selectedtask to 2
						set theContext to context "@Home"
						set context of Selectedtask to theContext
						compact
					end tell
				end tell
				-- end of the loop if it took < 2min
			else
				-- the task takes more than 2 min so we difne its parameters
				my definetask(Selectedtask)
			end if
			--end of determining if it takes more than 2min	
		end if
		-- end of determinig it is a project or not
	else
		set mylist to {"trash", "someday/maybe"}
		set choix to choose from list mylist with prompt "choose what to do"
		if choix is {"trash"} then
			tell application "OmniFocus"
				delete Selectedtask
			end tell
		end if
		
		if choix is {"someday/maybe"} then
			my project(Selectedtask, "Someday/Maybe Projects")
		end if
		
	end if
end Process

on definetask(Selectedtask)
	set projectName to choose from list projectnameList with prompt "affect a project to this action" as text
	
	set question1 to display dialog "are you the right person to do it?" buttons {"yes", "no"} default button 1
	set answer1 to button returned of question1
	if answer1 is "no" then
		set contextName to "Waiting"
		tell application "OmniFocus"
			tell front document
				set n to count projectnameList
				set test to (item n of projectnameList) as rich text
				repeat while n > 0
					set test to (item n of projectnameList) as rich text
					ignoring white space
						if projectName contains test then
							set refindex to n
						end if
					end ignoring
					set n to n - 1
				end repeat
				set idproject to (item refindex of projectidList) as rich text
				set taskNote to note of Selectedtask
				using terms from application "OmniFocus"
					set theProject to project id idproject
				end using terms from
				set assigned container of Selectedtask to theProject
				set context of Selectedtask to context contextName
			end tell
		end tell
		
	else
		set contextName to choose from list contextnameList with prompt "affect a context to this action " as text
		set n to count projectnameList
		set m to count contextnameList
		
		set test to (item n of projectnameList) as text
		set test2 to (item m of contextnameList) as text
		repeat while n > 0
			set test to (item n of projectnameList) as text
			ignoring white space
				if projectName contains test then
					set refindex to n
				end if
			end ignoring
			set n to n - 1
		end repeat
		repeat while m > 0
			set test2 to (item m of contextnameList) as text
			ignoring white space
				if contextName contains test2 then
					set refindex2 to m
				end if
			end ignoring
			set m to m - 1
		end repeat
		
		set idproject to (item refindex of projectidList) as text
		set idName to (item refindex of contextidlist) as text
		
		set question2 to display dialog "is it time specific?" buttons {"yes", "no"} default button 2
		set answer2 to button returned of question2
		if answer2 is "yes" then
			set comment to "time specific"
		else
			set comment to ""
		end if
		set mytimelist to {5, 10, 20, 30, 45, 60, 90, 120, 180}
		set estimatedtime to choose from list mytimelist with prompt "how many minutes will it take"
		considering numeric strings
			if estimatedtime is equal to 180 then
				set Alert to display dialog "this action will takes more than 2 hours,it is probably a GTD project, you should refine it" buttons {"OK", "Cancel"} default button 1
				set agreement to button returned of Alert
				if agreement is "OK" then
					my project(Selectedtask, "To mindmap")
				end if
				
				
			else
				tell application "OmniFocus"
					tell front document
						set taskNote to note of Selectedtask
						using terms from application "OmniFocus"
							set theProject to project id idproject
							set theContext to context id idName
						end using terms from
						set assigned container of Selectedtask to theProject
						set context of Selectedtask to theContext
						set note of Selectedtask to taskNote & return & comment
						set estimated minutes of Selectedtask to estimatedtime
						compact
					end tell
				end tell
			end if
		end considering
	end if
end definetask


on project(Selectedtask, locationname)
	tell application "OmniFocus"
		tell front document
			using terms from application "OmniFocus"
				set myfolder to a reference to folder locationname
				set noteproject to note of Selectedtask as rich text
				make new project at end of myfolder with properties {name:name of Selectedtask, note:noteproject}
				delete Selectedtask
			end using terms from
		end tell
	end tell
	
end project
Lionel

Last edited by lion3000; 2009-05-16 at 07:53 AM.. Reason: lack of the script
 
So, if I understand this correctly . . . this script is run within OF. I select several items in the Inbox, then run the script to go through the process you outlined?
 
Yes, and that's my first script, so it lacks of comments (i m not a programer) and it probably lacks of great tricks to speed its execution,so if you find it helps don't hesitate go give me your comments
Thanks a lot for your attention
Lionel
 
Pretty nice script, and a nice way to walk you through the process.

Some things that might be nice:

1) Have it ask you who should do the task, and assign it appropriately.
2) If it wants to use Someday/Maybe, or some other hardcoded Context/Project name, create those if needed (I got an error).
 
Hi and thanks for the script. Unfortunatelly it does not assign the right context. By that I mean that the context that is assigned to the task does not match the context I choose from the pop up menu within the script...
 
Hi all,
thanks for your answers, i've will do my homework this week to fix the bug you spotted, i'll post the fix next week

see you

Lionel
 
Great script. I like how it steps me through the "process." I would use it regularly if it was faster...and it would definitely be more user friendly if it included what "xmas" suggested.
 
Thanks for the script! I really love the idea, but I agree it could use a little cleaning up. I'm not even at your level of scripting, so I don't think I can help out much, but is anyone else working on it? If not I might just have to learn some scripting!
 
Hi there,
First and foremost, I apologise for digging up such an old and retired thread.
I was just curious, where did this script get to? Did it evolve into something better?

The last thing Lionel said was:
Quote:
thanks for your answers, i've will do my homework this week to fix the bug you spotted, i'll post the fix next week
Nothing posted though, so curious to know if it was dropped or if there's a better version kicking around somewhere?

Cheers,

Sam
 
This script could certainly be restored to health. For example, the loading delay - which has been commented on - could now be eliminated (in OF 1.8) by replacing all of the loading code, from "--chargement des contexts" to "--fin du chargement" with the much simpler and faster:

Code:
tell application id "com.omnigroup.OmniFocus"
	tell default document
		set {refContexts, refProjects} to {a reference to flattened contexts, a reference to flattened projects}
	end tell
	set {contextidlist, contextnameList} to {id, name} of refContexts
	set {projectidList, projectnameList} to {id, name} of refProjects
end tell
It could also be adjusted to create any assumed folders and contexts where necessary, etc etc
 
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Inbox Items not Cleaning Up adic26 OmniFocus 1 for Mac 2 2012-02-22 07:52 PM
Entering items in inbox malisa OmniFocus for iPad 2 2011-10-30 06:11 AM
Inbox Done Items gombau OmniFocus for iPhone 5 2011-06-01 01:10 AM
Process vs. organize and dealing with your email inbox avernet OmniFocus 1 for Mac 6 2009-07-18 05:23 AM
Inbox items stay in inbox after being assigned Project Roll OmniFocus 1 for Mac 2 2008-09-20 10:28 AM


All times are GMT -8. The time now is 01:27 PM.


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