Guest
2008-03-01, 01:03 AM
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..