The Omni Group Forums

The Omni Group Forums (http://forums.omnigroup.com/index.php)
-   OmniFocus Extras (http://forums.omnigroup.com/forumdisplay.php?f=44)
-   -   All tasks in a project? (http://forums.omnigroup.com/showthread.php?t=16559)

craig.martell 2010-06-21 08:21 PM

All tasks in a project?
 
ALL:

Thanks in advance for your help. I've been able to get a list of all the projects in my "default document" in OmniFocus (thanks to all the help here :-). However, I need to be able to print out every task in each project. Any ideas?

Here's my goal. When I send email to myself with a particular subject line, I want a scpt to fire off that goes to OmniFocus, gets a list like the following:

Project 1
Task 1
Task 2
. . .
Task N
Project 2
Task 1 . . .
etc.

and then sends it back to me in an email. Any help would be appreciated.

Thanks,

Craig

RobTrew 2010-06-21 11:15 PM

[QUOTE=craig.martell;79001]I've been able to get a list of all the projects in my "default document" [/QUOTE]

You may have seen from this forum that Tim Woods has made some very helpful enhancements to the OF Applescript library in the latest sneaky peek builds. These will enable you to get a list of all projects much more simply (see below).

[QUOTE=craig.martell;79001]I want a scpt to fire off that goes to OmniFocus, gets a list like the following:

Project 1
Task 1
Task 2
. . .
Task N
Project 2
Task 1 . . .
etc.

and then sends it back to me in an email.[/QUOTE]

You may find some re-usable elements in this approach:

[CODE]tell application "OmniFocus"
-- This approach to getting a flattened project list became possible in
-- in a recent 1.8 Sneak Peek build due to work by Tim Woods

-- ADJUST THE 'WHERE' CLAUSE TO FIT THE NEED
set lstProjects to flattened projects of default document where (status is active)

set strList to ("Projects " & (current date) as string) & return & return
repeat with oProj in lstProjects
set strList to strList & my TaskReport(oProj, "") & return
end repeat
end tell

tell application "Mail"
set oMsg to make new outgoing message with properties {content:strList & return & return}
set visible of oMsg to true
activate
end tell


on TaskReport(oParent, strIndent)
using terms from application "OmniFocus"
tell oParent
set strReport to strIndent & name & return
set strIndent to strIndent & tab

-- ADJUST THE 'WHERE' CLAUSE TO FIT THE NEED
set lstTasks to tasks where completed is false
repeat with oTask in lstTasks
set strReport to strReport & my TaskReport(oTask, strIndent)
end repeat
return strReport
end tell
end using terms from
end TaskReport
[/CODE]

craig.martell 2010-06-22 05:25 AM

Thanks Rob. I did see that the latest sneaky peak will help. I might give that a try. Thanks for the script as well. I will see what I can do with it.

Craig

craig.martell 2010-06-22 07:00 AM

That did it!!

Thanks again.

BTW, I like the recursion. I haven't been using nested tasks, but I might start now :-).

I have attached my version of the script, since I use Entourage and not Mail. I also added some code at the beginning that retrieves my Inbox tasks first (using your function).

[CODE]tell application "OmniFocus"
-- This approach to getting a flattened project list became possible in
-- in a recent 1.8 Sneak Peek build due to work by Tim Woods

-- ADJUST THE 'WHERE' CLAUSE TO FIT THE NEED
set lstProjects to projects of default document where (completed is false)

set strList to ("Projects " & (current date) as string) & return & return & "Inbox" & return
set in_box to inbox tasks of default document
repeat with aTask in in_box
set strList to strList & tab & my TaskReport(aTask, "")
end repeat
set strList to strList & return
repeat with oProj in lstProjects
set strList to strList & my TaskReport(oProj, "") & return
end repeat
end tell

tell application "Microsoft Entourage"
set subjectLine to ("Current Task List " & (current date) as string)
set strList to strList & return & return
set currentTaskList to make new outgoing message with properties {subject:subjectLine, content:strList, recipient:"email@domain.com"}
send currentTaskList
end tell


on TaskReport(oParent, strIndent)
using terms from application "OmniFocus"
tell oParent
set strReport to strIndent & name & return
set strIndent to strIndent & tab

-- ADJUST THE 'WHERE' CLAUSE TO FIT THE NEED
set lstTasks to tasks where completed is false
repeat with oTask in lstTasks
set strReport to strReport & my TaskReport(oTask, strIndent)
end repeat
return strReport
end tell
end using terms from
end TaskReport[/CODE]


All times are GMT -8. The time now is 02:04 AM.

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