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

 
Script: listing tasks by their creation date Thread Tools Search this Thread Display Modes
I needed to check the creation date of some tasks this morning.

You can do this with individual tasks through the OF menu - Inspectors > Action > Added.

What I wanted, however, was to select a range of tasks, and then see a list of them sorted in the order of their creation.

This script puts a tab-delimited list into the Clipboard. It list the selected tasks, sorted by the date on which they were added to the OmniFocus database.

Two date fields and a text field: Created, Modified, Name.

It can be pasted into something like Excel.

Code:
property pDateFormat : "%m/%d/%Y %H:%M"
property pDelim : "~|~"

-- OF SQL TIME BEGINS AT MIDNIGHT AT THE START OF 2001-01-01
property pDateZero : "strftime('%s','2001-01-01')"

on run
	tell application id "OFOC"
		tell content of front document window of front document
			set lstID to id of selected trees where its class is not item and its class is not folder
			set lngID to count of lstID
			if lngID < 1 then return
			set strCondn to "persistentIdentifier = \"" & first item of lstID & "\""
			if lngID > 1 then
				repeat with i from 2 to lngID
					set strCondn to strCondn & " or persistentIdentifier = \"" & item i of lstID & "\""
				end repeat
			end if
		end tell
	end tell
	
	set strCmd to "sqlite3 -separator " & quoted form of pDelim & " ~/Library/Caches/com.omnigroup.OmniFocus/OmniFocusDatabase2 " & quoted form of ("
SELECT " & OFDate("dateAdded") & ", " & OFDate("dateModified") & " , name 
FROM task where " & strCondn & "
ORDER by dateAdded")
	
	set lstTasks to paragraphs of (do shell script strCmd)
	set {dlm, my text item delimiters} to {my text item delimiters, pDelim}
	set beginning of lstTasks to {"Created", "Modified", "Action"}
	
	set lngLines to lngID + 1
	
	repeat with i from 1 to lngLines
		set item i of lstTasks to text items of item i of lstTasks
	end repeat
	
	set text item delimiters to tab
	repeat with i from 1 to lngLines
		set item i of lstTasks to (item i of lstTasks) as text
	end repeat
	
	set my text item delimiters to return
	set strReport to lstTasks as string
	set my text item delimiters to dlm
	
	display dialog ("Tab-delimited list of " & lngID as string) & " selected action(s), 
sorted by date added to the OmniFocus database, 
has been placed in Clipboard.

" & strReport buttons {"OK"} with title "Selected actions sorted by date added"
	set the clipboard to strReport
end run


on OFDate(strFieldName)
	"strftime('" & pDateFormat & "', " & strFieldName & " + " & pDateZero & ", 'unixepoch')"
end OFDate

Last edited by RobTrew; 2011-07-26 at 02:35 AM..
 
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Script for a quick listing of OmniFocus statistics RobTrew OmniFocus Extras 51 2014-02-17 02:58 AM
Simple Task Creation Script gotrevgo OmniFocus Extras 1 2011-10-19 11:57 AM
Script to locate tasks with a certain date in a note daltongreen OmniFocus Extras 4 2011-01-20 11:07 AM
Feature Request: Creation Date and Checkoff Date for Actions hagbard5235 OmniFocus 1 for Mac 3 2010-02-06 11:36 AM
Reporting or Listing Tasks by a Date Range? Ciscok1d OmniFocus 1 for Mac 3 2008-10-23 11:07 AM


All times are GMT -8. The time now is 05:19 AM.


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