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

 
Combining Tasks Thread Tools Search this Thread Display Modes
Hello all.

I'm looking for a script to combine two tasks and the notes in them.

I have 0 applescript skills– but I thought someone might be able to whip this up, or might have developed it already. Any advice would be appreciated

I often have a task in my database, along with a note containing the relevant details. Then, an email comes in from somewhere with additional information. In order to be sure not to miss it, I add this email to my inbox. Then, later, when sorting the inbox, I realize that this task is already in my database, but the additional email, now in the note of a second task in the inbox, is something I want to add to the existing task in my database. The process of combining these takes way to many clicks.

Any ideas?
 
note: I love the way the Mail Clip-o-tron handles input when multiple messages are selected. What I'm looking for is this kind of functionality for combining multiple tasks within Omnifocus.
 
Concatenating the notes from two or more tasks is a straightforward idea, but how would you propose to resolve the task name? Display them and pick one? Type in a new one? Arbitrarily choose one automatically and go with it?
 
hrmmm.... Well– In never noticed the way the clip-o-tron handles multiple messages, so I guess it handles them well...

I just checked.

I keeps the first message subject as the title of the task in omnifocus...

But then– in the first lines of the note of the task– it lists the subjects off all the source emails. Then, skips a line, and then underneath displays the body of all the messages. Something parallel would be great.
 
This script will combine two or more selected tasks. The first one is kept as the base and the rest are appended and then deleted. I haven't figured out how to retain any formatting that may be in the notes so the new task will be all plain text if that matters to you.

Code:
-- Combine two or more selected tasks into one
tell application "OmniFocus"
	tell document window 1 of default document
		set _trees to selected trees of content
		if (count of _trees) < 2 then
			display dialog "You must have more than one task selected"
		else
			set _tasksToDelete to {}
			set _masterTask to value of item 1 of _trees
			set _names to "From:  " & name of _masterTask
			set _notes to name of _masterTask & return & note of _masterTask
			repeat with i from 2 to count of _trees
				set _task to value of item i of _trees
				set end of _tasksToDelete to _task
				set _names to _names & return & "From:  " & name of _task
				if note of _task is not "" then
					set _notes to _notes & return & return & name of _task & return & note of _task
				end if
			end repeat
			set note of _masterTask to _names & return & return & _notes
			repeat with _task in _tasksToDelete
				delete _task
			end repeat
		end if
	end tell
end tell
 
Brilliant!!!!!

Thank you so much!

This is going to save me hours each week!
 
If you also wanted to preserve formatting you could back-up your data and then experiment with something like the following:

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)
		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 last 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 last 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
 
I definitely like the idea that you're checking to make sure what's selected are actually tasks. I should have added a caveat to my script that there wasn't any real error checking going on. However, "where (class of its value is task)" always results in lstTasks being empty for me. I had to remove that clause to get it to recognize the selected tasks.

Your script did preserve the formatting perfectly, but it took 13 seconds to combine two small emails. I'll have to examine what you're doing in more detail when I have time later.

Thanks for the update.
 
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..
 
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
combining planning view and context view Gizmo OmniFocus 1 for Mac 7 2011-11-23 12:47 PM
Combining lines stevechamp OmniGraffle General 1 2007-12-17 01:38 AM
Dividing and combining rows Harvey Leff OmniOutliner 3 for Mac 1 2007-11-25 11:41 AM
Combining two OmniFocus documents? jasong OmniFocus 1 for Mac 3 2007-07-03 02:42 PM
Combining shapes - masking, cutout, cutaway, compositing… chirsten OmniGraffle Extras 0 2006-11-22 03:17 PM


All times are GMT -8. The time now is 05:08 PM.


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