Combining Tasks
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.
|
Bump
|
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 [/code] |
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[/CODE] |
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=GrumpyDave;92531]where (class of its value is task) always results in lstTasks being empty for me.[/QUOTE]
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)[/CODE] [QUOTE=GrumpyDave;92531]it took 13 seconds to combine two small emails.[/QUOTE] 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[/CODE] [COLOR="White"]--[/COLOR] |
All times are GMT -8. The time now is 06:26 PM. |
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2024, vBulletin Solutions, Inc.