The Omni Group Forums

The Omni Group Forums (http://forums.omnigroup.com/index.php)
-   OmniFocus Extras (http://forums.omnigroup.com/forumdisplay.php?f=44)
-   -   Applescript - Tasks vs. Tree - huh? (http://forums.omnigroup.com/showthread.php?t=9580)

syncretist 2008-08-25 10:37 AM

Applescript - Tasks vs. Tree - huh?
 
I'm been trying to write a pair of scripts to make all the notes on tasks visible, or hidden. There's a set of scripts for OmniOutliner that do this I'm finding quite useful for other work.

It seems like I definitely am missing some conceptual premise of the relationship between tasks and trees in OmniFocus. A TASK seems to have all the attributes specifically tailored to the use of outlines within OmniFocus....but the "Note is expanded" boolean only exists for the trees class.

Can anyone enlighten me, suggest appropriate reading, or otherwise point in the right direction?

(am i misunderstanding the inheritance issues here? does that "note expanded" boolean exist for each task and perhaps I'm just not composing my script correctly?)

-Thanks,
Robert

Lizard 2008-08-25 12:19 PM

Tasks don't have the "note expanded" property. If you want to expand notes, you'll need to use the trees.

syncretist 2008-09-07 11:08 AM

I finally figured out the syntax
 
So here's the code I cobbled together from other examples; I made a script that will expand notes of all selected tasks, and if none are selected it expands the notes on all of them.

[CODE]
ell application "OmniFocus"
-- set note expanded of selectedItem to true
tell document 1
tell (first document window whose index is 1)


-- check to see if there is a selection or not
set SelectionV to selected trees of content
-- display dialog (count of SelectionV)
if (count of SelectionV) = 0 then
--display dialog "no selection"

set SelectionV to trees of content
-- handle first node
repeat with i from 1 to (count of SelectionV)
set note expanded of item i of SelectionV to true
end repeat

-- now handle descendants

set dTree to descendant trees of content

repeat with i from 1 to (count of dTree)
set note expanded of item i of dTree to true
end repeat
else
--display dialog "there are selections."
-- set SelectionV to trees of content
set SelectionV to selected trees of content

repeat with i from 1 to (count of SelectionV)
-- set ItemV to value of item i of SelectionV
set note expanded of item i of SelectionV to true
end repeat

end if
end tell
end tell

end tell

[/CODE]


Thanks to everyone who posts code here, i couldn't have figured this out without your help.

-Robert


All times are GMT -8. The time now is 03:01 PM.

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