Easy TeamworkPM automation on a Mac

In last year's May Newsletter, Email Dropboxes made their debut under the breathless heading:

"OMG!... You can now create tasks & messages via email!"

Sounds simple doesn't it? But there's a lot of potential hidden behind those exclamation marks.  One particularly easy thing to do, if you have a Mac, is to give yourself the ability to create a new task and assign it to yourself, by simply selecting some text.

That's any selected text, in any application, on a Mac.

Now this involves using an application that Apple provides called Automator. If you've never used it before don't worry, just follow along with this post and you'll be fine. It's simple, so simple in fact, that this post is mostly just a bunch of screenshots.

To get started, go to the Applications folder on your Mac and launch Automator.

Automator makes it very easy get your Mac to do all sorts of interesting things without requiring a degree in Computer Science. Most of the time you simply drag and drop a few actions to create powerful plugins for Mail, or iTunes or the Mac itself with zero effort. 

Which is what we're going to do now.
First thing, go create a new Service document in Automator.  

Now, you could simply play around with the "New Mail" and the "Send Mail" actions in Automator and have the whole service working without any typing at all, but we're going to go a little further and use a script so that we can automatically specify who to assign the task too.

In the top left of your new Automator window, start typing AppleScript until you find the "Run AppleScript" action.

Drag that action over to the right hand side of Automator and delete all of the placeholder text in it.  We'll be adding our own script in the next step.

To get the service to do what we want, simply copy in the little bit of AppleScript shown below.  AppleScript prides itself on looking something like English, but don't worry you don't have to try figure out what it does if you don't want to!

on run {selectedText, parameters} 

tell application "Mail"

----------- Don't forget to change myName and emailAddress to your details!!! ---------

set myName to "mike" 

 set emailAddress to "TWiPhoneAppBugs.I_EAT_BUGS_FOR_BREAKFAST@t asks.teamworkpm.net"

---------------------------------------

set theTaskTitle to "@" & myName & " " & selectedText

set theMessage to make new outgoing message with properties {visible:true, subject:theTaskTitle, content:""}

tell theMessage 

 make new to recipient at end of to recipients with  properties {name:"Bugs", address:emailAddress}

 

end tell

send theMessage

end tell

return selectedText 

 end run

To automatically assign the task to yourself, change the value of myName to your own name.   You could of course specify the name of someone else on the project if you want to assign the task to them.

Finally change the value of emailAddress to the unique email address for the task list that you're interested in. To find that address go to Teamwork and click on the option menu beside the name of the task list. Choose the "Email tasks to this list" option.

Copy the email address and paste it into the AppleScript.

Now that you've made the changes, hit the hammer button at the top of the AppleScript to build it. If everything is typed in correctly the script will change colour nicely and your document should look something like this:

And that's it! Just save the document and give it a useful name. In this example I've created a service to send tasks to my bug task list so I named the service app : "Send Task To Bug List"

And now the fun bit - go select any text and bring up the contextual menu for it ( you can do that by holding down the control key when you click on the selected text ) and you'll find that you are now able to magically send that piece of text to your task list as a new task.

Simple isn't it? The possibilities are endless - create as many services as you like for all of your favorite task lists and message categories.

And if you come up with a good Automator script don't forget to let us know so that we can share it with every one else!

That's it, as usual, let us know what you think. 

Mike.