The Omni Group Forums

The Omni Group Forums (http://forums.omnigroup.com/index.php)
-   OmniFocus Extras (http://forums.omnigroup.com/forumdisplay.php?f=44)
-   -   routine to process inbox items (http://forums.omnigroup.com/showthread.php?t=12541)

lion3000 2009-05-16 07:50 AM

routine to process inbox items
 
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 :

[B]what is the outcome of this item?[/B] (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

[B]does it require more than 1 action?[/B][INDENT][/INDENT]-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 [URL="http://forums.omnigroup.com/showthread.php?t=7802"]here[/URL] to transcript it in omnifocus)
-if no it asks the questions
[B]does it take more than 2 min?[/B] )> yes pops up a do it! display dialog
if no
it asks which existing project you want to assign the item
then
[B]are you the right person to do it ?[/B]
(if no it assign the task to context "waiting")
if yes then it ask [B]which context is required to do the task[/B]
and then it ask [B]if it is time specific[/B] (if yes it tags the task "time specific" to get it in a specific perspective)
and off course it ask [B]how much time i need to do the task[/B] (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



[/CODE]
Lionel

lolajl 2009-05-17 03:17 PM

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?

lion3000 2009-05-17 08:20 PM

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

xmas 2009-05-18 10:36 AM

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).

velvet 2009-06-02 03:39 AM

nice, but buggy
 
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...

lion3000 2009-06-02 07:49 PM

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

bpwhistler 2009-08-17 08:19 AM

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.

invictus26 2009-09-19 11:18 PM

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!

luminosity 2010-10-14 07:14 PM

What did this evolve into?
 
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[/QUOTE]
Nothing posted though, so curious to know if it was dropped or if there's a better version kicking around somewhere?

Cheers,

Sam

RobTrew 2010-10-15 02:20 AM

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[/CODE]

It could also be adjusted to create any assumed folders and contexts where necessary, etc etc


All times are GMT -8. The time now is 11:52 AM.

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