Thread: Combining Tasks
View Single Post
Quote:
Originally Posted by GrumpyDave View Post
where (class of its value is task) always results in lstTasks being empty for me.
Sounds like you may (quite naturally) be selecting inbox tasks rather than project tasks.

Extending the condition should fix that problem:

Code:
(class of its value is task or class of its value is inbox task)

Quote:
Originally Posted by GrumpyDave View Post
it took 13 seconds to combine two small emails.
Yes, working with references to the formatted text is certainly much slower than working with plain text. Not that slow on my system, but still a clear difference. For speed, plain text is clearly the way to go.

[NOTE - THE FOLLOWING SHOULD PROBABLY BE TREATED PURELY AS A CURIOSITY - IT APPARENTLY RUNS VERY SLOWLY, TO THE POINT OF TIMEOUT AND FREEZE, ON SOME SYSTEMS]

Code:
tell application id "com.omnigroup.omnifocus"
	tell content of front document window of front document
		set lstTasks to value of selected trees where (class of its value is task or class of its value is inbox task)
		if length of lstTasks < 2 then return
		set oFirstTask to first item of lstTasks
		set lstRest to items 2 thru end of lstTasks
		
		tell oFirstTask -- INSERT TITLE OF FIRST TASK AT START OF ITS OWN NOTE
			insert name & return & return at before characters of note
			duplicate first character of note to after last character of note
			insert return & return at before last character of note
			delete last character of note
			
			repeat with oTask in lstRest -- APPEND TITLES AND NOTES OF OTHER TASKS TO NOTE OF FIRST TASK
				duplicate first character of note to after last character of note
				insert ((return & return & (name of oTask) as string) & return & return) at before (last character of note)
				delete last character of note
				duplicate (characters of note of oTask) to after (characters of note)
				delete oTask
			end repeat
		end tell
	end tell
end tell


--

Last edited by RobTrew; 2011-02-05 at 12:55 PM..