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

 
Applescript - Tasks vs. Tree - huh? Thread Tools Search this Thread Display Modes
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
 
Tasks don't have the "note expanded" property. If you want to expand notes, you'll need to use the trees.
 
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

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

-Robert
 
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
applescript for common OF tasks steve OmniFocus 1 for Mac 4 2012-02-15 06:11 AM
Applescript to turn an xml file into a tree of shapes ianpiper OmniGraffle General 2 2008-06-16 08:04 PM
Selecting new tasks via Applescript scb OmniFocus Extras 3 2007-09-06 11:30 PM
Applescript Help: getting a list of tasks tweir OmniPlan General 3 2007-01-10 03:33 PM


All times are GMT -8. The time now is 10:46 AM.


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