fmantek
2008-04-29, 10:48 PM
I use Omnifocus a lot, and the thing that bugged me about it (or i am just to dumb to figure out how to do it) is that it does not help me a lot answering snippet emails..... I could not find a good way to create a report that showed: this is what i did last week...
If there is such a way, please tell me :)
so i wrote the applescript below that walks over the omnifocus database and creates a bbedit text file with dates/titles/shortnotes looking like this:
"30/4/08 .NET Library work
30/4/08 Add solution file to VS 2005 setup
30/4/08 Add deleted detection code on the contact object..
30/4/08 Add email constructor for primary and rel
30/4/08 Verify that the Contacts template is part of the setup
30/4/08 64 bit patch
Re: GData.NET for Windows x64
30/4/08 Released 1.1.4.1 Maintainance release
Added PrimaryEmail, PrimaryPostalAddress, PrimaryPhonenumber and PrimaryIMAddres
"
Note this is the first applescript i ever wrote, so if you think it can use improvements, let me know :) always eager to learn - i found getting into applescript not that easy...
If you want to use this without BBEdit, all you have to do is change the method BBEditOutput to use another application.
global theDate
global targetDate
set theDate to current date
set targetDate to theDate - 7 * days
tell application "OmniFocus" to activate
tell front document of application "OmniFocus"
set alertReply to display alert "Ready to generate outline" message "This process could take several minutes, during which OmniFocus and BBEdit will be unavailable for other tasks." as warning buttons {"OK", "Cancel"} default button "Cancel"
if (button returned of alertReply is "Cancel") then return
set topLevelProjectsAndFolders to every section
end tell
tell application "BBEdit"
activate
make new document
end tell
createReport(topLevelProjectsAndFolders)
on createReport(theProjects)
if (theProjects is {}) then return
createLine(item 1 of theProjects)
createReport(rest of theProjects)
end createReport
on createLine(anItem)
BBEditOutput(anItem)
createChildren(anItem)
end createLine
on BBEditOutput(anItem)
local rowData, nextLine, n
set rowData to getRowData from anItem
if (rowData is not {}) then
tell front window of application "BBEdit"
set sd to short date string of (rowDate of rowData)
set nextLine to sd & " " & (rowTopic of rowData) & return as Unicode text
select insertion point after last character
set selection to nextLine
try
set maxLength to 80
set n to (rowNote of rowData) as Unicode text
if (length of n > maxLength) then
set n to characters 1 thru maxLength of n
end if
if (length of n > 1) then
set n to " " & n & return
select insertion point after last character
set selection to n
end if
-- insert a blank
select insertion point after last character
set selection to return
on error
-- ignore error, there might not be a note, or it's to short
end try
end tell
end if
end BBEditOutput
on getRowData from anItem
using terms from application "OmniFocus"
set theModification to modification date of anItem
set theTopic to name of anItem
set theNote to (note of anItem)
end using terms from
if (theModification > targetDate) then
return {rowTopic:theTopic, rowNote:theNote, rowDate:theModification}
else
return {}
end if
end getRowData
-- anItem is an OF folder, project, or action
-- aRow is an OmniOutliner row
on createChildren(anItem)
using terms from application "OmniFocus"
try
-- First see if anItem is a folder
set itemChildren to every section of anItem
on error
-- Error says anItem isn't a folder, so see if it is a project
try
set anItem to root task of anItem
on error
-- Error says anItem isn't a project, so it must be a task
end try
set itemChildren to every task of anItem
end try
end using terms from
createChildrenHelper(itemChildren)
end createChildren
-- itemChildren is a list of OF folders, projects, and actions
-- aRow is an OmniOutliner row
on createChildrenHelper(itemChildren)
if (itemChildren is {}) then return
set childItem to item 1 of itemChildren
BBEditOutput(childItem)
createChildren(childItem)
createChildrenHelper(rest of itemChildren)
end createChildrenHelper
If there is such a way, please tell me :)
so i wrote the applescript below that walks over the omnifocus database and creates a bbedit text file with dates/titles/shortnotes looking like this:
"30/4/08 .NET Library work
30/4/08 Add solution file to VS 2005 setup
30/4/08 Add deleted detection code on the contact object..
30/4/08 Add email constructor for primary and rel
30/4/08 Verify that the Contacts template is part of the setup
30/4/08 64 bit patch
Re: GData.NET for Windows x64
30/4/08 Released 1.1.4.1 Maintainance release
Added PrimaryEmail, PrimaryPostalAddress, PrimaryPhonenumber and PrimaryIMAddres
"
Note this is the first applescript i ever wrote, so if you think it can use improvements, let me know :) always eager to learn - i found getting into applescript not that easy...
If you want to use this without BBEdit, all you have to do is change the method BBEditOutput to use another application.
global theDate
global targetDate
set theDate to current date
set targetDate to theDate - 7 * days
tell application "OmniFocus" to activate
tell front document of application "OmniFocus"
set alertReply to display alert "Ready to generate outline" message "This process could take several minutes, during which OmniFocus and BBEdit will be unavailable for other tasks." as warning buttons {"OK", "Cancel"} default button "Cancel"
if (button returned of alertReply is "Cancel") then return
set topLevelProjectsAndFolders to every section
end tell
tell application "BBEdit"
activate
make new document
end tell
createReport(topLevelProjectsAndFolders)
on createReport(theProjects)
if (theProjects is {}) then return
createLine(item 1 of theProjects)
createReport(rest of theProjects)
end createReport
on createLine(anItem)
BBEditOutput(anItem)
createChildren(anItem)
end createLine
on BBEditOutput(anItem)
local rowData, nextLine, n
set rowData to getRowData from anItem
if (rowData is not {}) then
tell front window of application "BBEdit"
set sd to short date string of (rowDate of rowData)
set nextLine to sd & " " & (rowTopic of rowData) & return as Unicode text
select insertion point after last character
set selection to nextLine
try
set maxLength to 80
set n to (rowNote of rowData) as Unicode text
if (length of n > maxLength) then
set n to characters 1 thru maxLength of n
end if
if (length of n > 1) then
set n to " " & n & return
select insertion point after last character
set selection to n
end if
-- insert a blank
select insertion point after last character
set selection to return
on error
-- ignore error, there might not be a note, or it's to short
end try
end tell
end if
end BBEditOutput
on getRowData from anItem
using terms from application "OmniFocus"
set theModification to modification date of anItem
set theTopic to name of anItem
set theNote to (note of anItem)
end using terms from
if (theModification > targetDate) then
return {rowTopic:theTopic, rowNote:theNote, rowDate:theModification}
else
return {}
end if
end getRowData
-- anItem is an OF folder, project, or action
-- aRow is an OmniOutliner row
on createChildren(anItem)
using terms from application "OmniFocus"
try
-- First see if anItem is a folder
set itemChildren to every section of anItem
on error
-- Error says anItem isn't a folder, so see if it is a project
try
set anItem to root task of anItem
on error
-- Error says anItem isn't a project, so it must be a task
end try
set itemChildren to every task of anItem
end try
end using terms from
createChildrenHelper(itemChildren)
end createChildren
-- itemChildren is a list of OF folders, projects, and actions
-- aRow is an OmniOutliner row
on createChildrenHelper(itemChildren)
if (itemChildren is {}) then return
set childItem to item 1 of itemChildren
BBEditOutput(childItem)
createChildren(childItem)
createChildrenHelper(rest of itemChildren)
end createChildrenHelper