The Omni Group Forums

The Omni Group Forums (http://forums.omnigroup.com/index.php)
-   AppleScripting Omni Apps (http://forums.omnigroup.com/forumdisplay.php?f=46)
-   -   OmniFocus: Querying tasks in Applescript gives odd results (http://forums.omnigroup.com/showthread.php?t=7350)

RobTrew 2008-03-01 02:03 AM

OmniFocus: Querying tasks in Applescript gives odd results
 
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
[/CODE]


All times are GMT -8. The time now is 09:31 PM.

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