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

 
Script for getting rid of task notes automatically? Thread Tools Search this Thread Display Modes
Hello.

I've setup certain iCal alarms to show up in OF as tasks (via the +omnifocus email).

Everything is great, except for one detail:
OmniFocus will add as a Note the title of the iCal event.
This is a big deal to me because I use notes exclusively for tasks that have actual notes I need to read. The way it is now, it annoys me to open a note only to find out it is not really a note but some iCal debris.

I realize this is the way iCal emails the alarms (it copies into the body of the email the title of the event). So my question is:

Is there some kind of script that will either, prevent iCal from emailing the events like that, or one that removes that text/note from OmniFocus, or even from the email itself just before OF grabs it?

Thank you in advance.

Last edited by FMiguélez; 2011-07-21 at 08:54 PM.. Reason: Changing the status to Resolved issue
 
Here's a little script which will strip the notes from the selected rows. Note that selecting a project without selecting its contained actions will only strip the note from the project itself.
Attached Files
File Type: applescript Clear Selected Notes.applescript (432 Bytes, 1426 views)
 
Hi, whPalmer4.

You are giving me hope!

Since I am just starting to find out scripting, I didn't know what to do with yours...
I know it works because I could call the script from the Scripts menu in the Menu bar. So I just select the tasks whose notes I want deleted, select the script from the menu and voila!

Now, while it works, I would need something more sophisticated if I want to really automate this.
I would like to automatically erase the notes from the tasks that go into OF via a "+omnifocus" email.

I tried adding another Run Script command in Mail's rule (after the default OF script), but rules only admit one script.
I tried placing your script on another rule immediately below, but it didn't work (obviously).

I tried opening OF's default Mail Action applescript and pasting at the end of it your script. It was a looooooooong newbie shot, and it didn't work either (no wonder).

I guess what I'd need to do is to add to the OF's Mail Action Script a section where those tasks get selected and pass that selection to your script. That would do what I want automatically, yes?

Is there a way to join those 2 scripts into one?
Would that require lots of extra code, or a simple joining routine could work?

I've been messing around with the scripting dictionaries. This is not the kind of thing one learns in an evening... I'd probably need months of study to learn to make my own scripts.
I will schedule some time every week for learning this little by little.

In the mean time, am I in the right path?
Any pointers or suggestions I could research?

Thank you : >)
 
You didn't pay for the deluxe version? :-)

Okay, if you really to automate this, this appears to work. Make a new rule in Mail which appears above your existing OmniFocus rule(s). Have it only run on messages sent by iCal, which it appears you can determine by looking to see if the subject begins with "Alarm - ". The rule then runs the following script instead of the one inside the OmniFocus application, and strips away the content of the message before handing it to OmniFocus. It's a trivial change to the OmniFocus version of the script, but you're accepting responsibility for making sure that you track any changes they might make to the original. You could of course replace the original, but that means you have to repeat the process each time you update OmniFocus.

Here's a snapshot of the rule I used to test that the script didn't break any existing functionality (except, of course, the ability to send a message which starts with "Alarm - "!). You could use something like this instead of the rule installed by OmniFocus if you are comfortable that everything still works with this change in place.






The edited version of the script appears below. Make sure you set up your rule to point to wherever you've saved the compiled version.

Code:
-- Copyright 2007 The Omni Group.  All rights reserved.
--
-- $Header: svn+ssh://source.omnigroup.com/Source/svn/Omni/branches/OmniFocus/1.9.x/OmniGroup/Applications/OmniFocus/App/Preferences/MailAction.applescript 110059 2009-03-12 04:33:13Z kc $

using terms from application "Mail"
	-- Trims "foo <foo@bar.com>" down to "foo@bar.com"
	on trim_address(theAddress)
		try
			set AppleScript's text item delimiters to "<"
			set WithoutPrefix to item 2 of theAddress's text items
			set AppleScript's text item delimiters to ">"
			set MyResult to item 1 of WithoutPrefix's text items
		on error
			set MyResult to theAddress
		end try
		set AppleScript's text item delimiters to {""} --> restore delimiters to default value
		return MyResult
	end trim_address
	
	
	on process_message(theMessage)
		tell application "OmniFocus"
			log "OmniFocus calling process_message in MailAction script"
		end tell
		-- Allow the user to type in the full sender address in case our trimming logic doesn't handle the address they are using.
		set theSender to sender of theMessage
		set trimmedSender to my trim_address(theSender)
		tell application "OmniFocus"
			set AllowedSender to allowed mail senders
			if AllowedSender does not contain trimmedSender and AllowedSender does not contain theSender then
				return
			end if
		end tell
		
		set theSubject to subject of theMessage
		set singleTask to false
		if (theSubject starts with "Fwd: ") then
			-- Whole forwarded messages shouldn't split.
			set singleTask to true
			set theSubject to text 6 through -1 of theSubject
		end if
		
		set theText to theSubject & return & content of theMessage
		if (theSubject starts with "Alarm - ") then
			-- iCal reminder, strip off unwanted message body
			set theText to theSubject & return
		end if
		tell application "OmniFocus"
			tell default document
				parse tasks with transport text theText as single task singleTask
			end tell
		end tell
	end process_message
	
	on perform mail action with messages theMessages
		try
			set theMessageCount to count of theMessages
			repeat with theMessageIndex from 1 to theMessageCount
				my process_message(item theMessageIndex of theMessages)
			end repeat
		on error m number n
			tell application "OmniFocus"
				log "Exception in Mail action: (" & n & ") " & m
			end tell
		end try
	end perform mail action with messages
end using terms from

The added lines are simply:

Code:
		if (theSubject starts with "Alarm - ") then
			-- iCal reminder, strip off unwanted message body
			set theText to theSubject & return
		end if
 
.

This is GREAT!

I have to tell you I am VERY happy. These are a few of the reasons, all related:

- Doing what I wanted IS possible

- You were kind enough to come up with a great and easy solution for me and posted it : >)

- I started getting into scripts (watched a bunch of tutorials) and found out how powerful they can be. They are approachable and I could learn them well.

- I found the solution you offered me on my own by "brute force" (I spent the whole night reading/watching tutorials about scripts and trying out things in Mail and iCal. I was trying to change the way iCal emails the messages. None of that worked, but then, with the little basic scripting knowledge I acquired throughout the night, I opened OF's script instead and found the lines:

set theText to theSubject & return & content of theMessage

It was the only place where I could see some kind of reference to the mail message. At first I tried deleting everything after the first & sign... It didn't work.
So I tried only deleting the & content of theMessage part and leaving the rest alone. It worked!!

Not as elegant as your solution, and it took me the full night to discover it, but the key thing was always in that little line of code.

Obviously, your solution is more sophisticated and better implemented. But you've inspired me to continue learning about scripting.
I'll approach it as learning a new language (so I'll speak spanish -my native language- English and scripting ! ).


Palmer, than you so much for your help!
I hope I can repay it one day by helping others when I become an expert OF user (you've certainly been contributing to this!).

Also, I will post here a few of the video tutorials I watched yesterday. They were extremely helpful (at an introductory level) and made me understand how it all fits together. Hopefully someone will find them useful.

I'll do that ASA get home.

Again, thank you very much!
 
That's pretty awesome, Bill - thanks. :-)
 
Hello.

These are some of the sources that are helping me get started with scripting.

They are ultra-simple and basic for most of you, but if there is a beginner, like me, who is wondering about scripts, they could be helpful.

This is a great intro tutorial by an Apple guru:
http://www.macosxautomation.com/appl...o-seminar.html

Also, this iTunes podcast is very nice. It's too general, but it helps giving a starting point:
It's called: Mac Automation Made Simple, by Ben Waldie

I am currently reading this too:
http://macosxautomation.com/applescr...ial/index.html



I am trying to make the discussed script of this thread smarter.
I'll post my resutls (if I can figure it out! )

: >)

Cheers!
 
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Automatically create a waiting for task? alexius OmniFocus 1 for Mac 29 2013-07-11 05:27 AM
Next sibling action's due-date automatically set when previous task complete? [A: feat. req. filed.] Toivonen OmniFocus 1 for Mac 1 2013-02-04 12:37 PM
Help. Script to automatically hide a layer??? mtwentythree OmniGraffle Extras 0 2009-09-23 12:09 PM
task groups [sub-projects ] are automatically sequential ?? ext555 OmniFocus 1 for Mac 2 2007-09-04 01:25 PM
Shouldn't task get automatically moved to projects? tango OmniFocus 1 for Mac 8 2007-07-29 04:05 AM


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


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