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 > Developer > AppleScripting Omni Apps
FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
OmniFocus: Querying tasks in Applescript gives odd results Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
You can query Omnifocus tasks to collect subsets with shared property values.

The results yielded are, however, imperfect. Querying by note content partially works but querying by due date seems to yield wholly incorrect results. Has anyone else tried this ?

Some sample test code:

Code:
tell application "OmniFocus"
	tell window 1
		set selected view mode identifier to "project"
		set focus to {}
		select library of sidebar
		
		tell content
			set refLeaves to a reference to leaves
			-- get total count of tasks
			set intTotal to count of refLeaves
			
			-- THIS QUERY ALMOST WORKS
			set lstSubSet to refLeaves where ((class of value) = task) and (note of value ≠ "")
			set intHasNote to count of lstSubSet
			
			set lstSubSet to refLeaves where ((class of value) = task) and (note of value = "")
			set intNoNote to count of lstSubSet
			
			set intDiscrepancy to intTotal - (intHasNote + intNoNote)
			display dialog "Gap: " & intDiscrepancy as string
			
			
			-- QUERYING ON DATES GIVES COMPLETELY INCORRECT RESULTS
			set lstSubSet to refLeaves where ((class of value) = task) and ((due date of value) is (current date))
			set intToday to count of lstSubSet
			
			set lstSubSet to refLeaves where ((class of value) = task) and ((due date of value) > (current date))
			set intAfterToday to count of lstSubSet
			
			set lstSubSet to refLeaves where ((class of value) = task) and ((due date of value) < (current date))
			set intB4Today to count of lstSubSet
			
			
			set intSecndDiscrepancy to intTotal - (intToday + intAfterToday + intB4Today)
			display dialog "Second Gap: " & intSecndDiscrepancy as string
			
			-- ODDEST RESULT -- Small positive number - hard to explain
			set lstSubSet to refLeaves where ((due date of value) ≠ (current date))
			set intOdd to count of lstSubSet -- Small positive number - hard to explain
			display dialog "Odd value for tasks with due date NOT today: " & intOdd as string
		end tell
	end tell
end tell

Last edited by RobTrew; 2008-03-01 at 06:24 AM..
 
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
7.5hr day still results in 8hr default tasks alexb OmniPlan General 2 2012-05-03 09:04 AM
OmniFocus bought thru AppStore: Cache-querying scripts fail RobTrew OmniFocus Extras 1 2011-06-29 03:38 PM
OF Applescript bug: querying for dates with missing values RobTrew OmniFocus Extras 2 2010-07-09 03:26 PM
AppleScript: Transfer tasks from THL (The Hit List) to OmniFocus eatmytag OmniFocus Extras 7 2009-11-01 01:59 AM
Omnigraffle Pro, AppleScript, Two Documents, Record Results cykyc OmniGraffle General 0 2007-04-20 03:58 PM


All times are GMT -8. The time now is 04:22 PM.


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