Tweaking OmniFocus: Project Template Applescript

OmniFocus is an amazing tool. I need this app like Smeagol needs his ring. If I don’t do my morning task audit, I get the shakes and start blurting out incoherent rambling about blown deadlines and crashing plates.

One feature missing in my precious however is the ability to create project templates. Everybody has some little group of tasks that gets repeated. For instance, I had a set of tasks that got repeated for each chapter of The Book. So how do I use this unsupported feature in OmniFocus? The answer is Applescript, that ubiquitous tool (that almost nobody uses) that lets you add features and bolt applications together like so many pieces of a digital erector set. In this case, I didn’t even write the script myself. Instead, I downloaded from Curt Clifton’s outstanding collection of OmniFocus scripts. Specifically, I’m using the Populate Template Placeholders script.

The download includes instructions but since so many find Applescript intimidating, I’m going to walk through it.

First a word about Applescript

Applescript is Apple’s own natural language scripting language that lets Macintosh applications hook up. You can tell one application to generate data and then send that data to a different application to lay it out, or print it, or post it to the Internet. It enables you to make your good apps great and your great apps awesome. It takes a little bit of time to figure out. The best way to learn it is to buy Sal’s book.

Regardless, even if you don’t want to learn Applescript, you can still use it. People like Curt develop all sorts of useful scripts and then post them to the Interwebs. You just download, install, and use without knowing a lick of Applescript code. This template script is just such an example. So here is how you go about it with my Mac Power Users show template:

Step 1: Install

Download the script and copy the script file to your script directory, located at:

~/Library/Scripts/Applications/OmniFocus

Most likely you don’t have an OmniFocus directory, so create one.

Step 2: Create

Create a project template in OmniFocus. This is set of tasks the Applescript will copy and populate for every new instance of the project.

Starting out, it looks just like any other project you may create except this one is more generic and includes Placeholders (nerd translation: variables). Placeholders are declared by adding them to the last line of the Notes section of the project description. They get surrounded by guillemets, those double-bracket looking symbols «like this». You can create them on a US keyboard by pressing (Option + \) for « and (Option + Shift + \) for ».

Once declared you can add the Placeholders to your project name and task items. As you can see from the example, I’ve created placeholders for the show name and show number. (If you want to prove your geek cred, open the Applescript and change the Placeholder symbols to something else.)

Step 3: Run

You can run the script from the script menu in your menubar. If you don’t see the script menu, which looks like this …

you can enable it in the preference pane of Applescript editor, an application on every Mac found in the Applications/Utilities folder.

Once you trigger the script, Applescript prompts you for the Placeholder variables …

and creates a new project replacing the Placeholders with your supplied data. Once you’ve got the script installed, setting up new templates projects takes a fraction of the time it did before.

Step 4: Drag

Drag the newly created project to wherever it belongs in your OmniFocus Project list.

Bonus Points

If you want to add start and due dates to templates projects, go nuts. The project itself, however, must have a start or due date in order for it work. Alternatively, if you add a line to the Project Template Note (above the Placeholder line) that reads Due date is, you will be prompted to type in your dates when you run the script. While I like start dates, I’m not a big fan of due dates and prefer adding dates (if any) manually later.

If you like the script, send Curt a thank you note for making this possible.

MacSparky.com is sponsored by Bee Docs Timeline 3D. Make a timeline presentation with your Mac.

46 Comments Tweaking OmniFocus: Project Template Applescript

  1. lamike@mac.com

    David: Thank you so very much for this post. I have been trying to get my head around OmniFocus AppleScripts for weeks. This piece just put everything in place. Thank you!

    This is, indeed, an elegant script and I have sent Curt a thank you note. I encourage you to continue publishing anything you think important about OmniFocus.

    Speaking of publishing, I bought the dead tree version of Mac At Work the day it appeared on Amazon, had it shipped overnight, and have reached Chapter 20. Many, many clipped pages. Thank you for this tremendous contribution to Mac education.

    Reply
  2. lamike@mac.com

    David: Thank you so very much for this post. I have been trying to get my head around OmniFocus AppleScripts for weeks. This piece just put everything in place. Thank you!

    This is, indeed, an elegant script and I have sent Curt a thank you note. I encourage you to continue publishing anything you think important about OmniFocus.

    Speaking of publishing, I bought the dead tree version of Mac At Work the day it appeared on Amazon, had it shipped overnight, and have reached Chapter 20. Many, many clipped pages. Thank you for this tremendous contribution to Mac education.

    Reply
  3. lamike@mac.com

    David: Thank you so very much for this post. I have been trying to get my head around OmniFocus AppleScripts for weeks. This piece just put everything in place. Thank you!

    This is, indeed, an elegant script and I have sent Curt a thank you note. I encourage you to continue publishing anything you think important about OmniFocus.

    Speaking of publishing, I bought the dead tree version of Mac At Work the day it appeared on Amazon, had it shipped overnight, and have reached Chapter 20. Many, many clipped pages. Thank you for this tremendous contribution to Mac education.

    Reply
  4. lamike@mac.com

    David: Thank you so very much for this post. I have been trying to get my head around OmniFocus AppleScripts for weeks. This piece just put everything in place. Thank you!

    This is, indeed, an elegant script and I have sent Curt a thank you note. I encourage you to continue publishing anything you think important about OmniFocus.

    Speaking of publishing, I bought the dead tree version of Mac At Work the day it appeared on Amazon, had it shipped overnight, and have reached Chapter 20. Many, many clipped pages. Thank you for this tremendous contribution to Mac education.

    Reply
  5. lamike@mac.com

    David: Thank you so very much for this post. I have been trying to get my head around OmniFocus AppleScripts for weeks. This piece just put everything in place. Thank you!

    This is, indeed, an elegant script and I have sent Curt a thank you note. I encourage you to continue publishing anything you think important about OmniFocus.

    Speaking of publishing, I bought the dead tree version of Mac At Work the day it appeared on Amazon, had it shipped overnight, and have reached Chapter 20. Many, many clipped pages. Thank you for this tremendous contribution to Mac education.

    Reply
  6. whpalmer4+macsparky@gmail.com

    James,

    your problem is almost certainly that you didn't put in the list of placeholders in the notes field of your template project. I've attached an example that shows what it should look like.

    Also, you need to set a due or start date for the template project if you want to have date substitution done. It uses the dates you put in the template to compute the adjustments to the date you supply. For your example, I would set the start date of the template project to today, and have that test «ActionName» action have a start date of today. Then when the script runs, it prompts you for the start date, sets the newly created project to start on that date, and goes through filling in the placeholders with the dates adjusted to fit. If your template project started on the 10th, and you had an action starting on the 13th, when it gets to that action it will add 13-10=3 days to the start date of the project you supplied when prompted.

    Reply
  7. whpalmer4+macsparky@gmail.com

    James,

    your problem is almost certainly that you didn't put in the list of placeholders in the notes field of your template project. I've attached an example that shows what it should look like.

    Also, you need to set a due or start date for the template project if you want to have date substitution done. It uses the dates you put in the template to compute the adjustments to the date you supply. For your example, I would set the start date of the template project to today, and have that test «ActionName» action have a start date of today. Then when the script runs, it prompts you for the start date, sets the newly created project to start on that date, and goes through filling in the placeholders with the dates adjusted to fit. If your template project started on the 10th, and you had an action starting on the 13th, when it gets to that action it will add 13-10=3 days to the start date of the project you supplied when prompted.

    Reply
  8. whpalmer4+macsparky@gmail.com

    James,

    your problem is almost certainly that you didn't put in the list of placeholders in the notes field of your template project. I've attached an example that shows what it should look like.

    Also, you need to set a due or start date for the template project if you want to have date substitution done. It uses the dates you put in the template to compute the adjustments to the date you supply. For your example, I would set the start date of the template project to today, and have that test «ActionName» action have a start date of today. Then when the script runs, it prompts you for the start date, sets the newly created project to start on that date, and goes through filling in the placeholders with the dates adjusted to fit. If your template project started on the 10th, and you had an action starting on the 13th, when it gets to that action it will add 13-10=3 days to the start date of the project you supplied when prompted.

    Reply
  9. whpalmer4+macsparky@gmail.com

    James,

    your problem is almost certainly that you didn't put in the list of placeholders in the notes field of your template project. I've attached an example that shows what it should look like.

    Also, you need to set a due or start date for the template project if you want to have date substitution done. It uses the dates you put in the template to compute the adjustments to the date you supply. For your example, I would set the start date of the template project to today, and have that test «ActionName» action have a start date of today. Then when the script runs, it prompts you for the start date, sets the newly created project to start on that date, and goes through filling in the placeholders with the dates adjusted to fit. If your template project started on the 10th, and you had an action starting on the 13th, when it gets to that action it will add 13-10=3 days to the start date of the project you supplied when prompted.

    Reply
  10. whpalmer4+macsparky@gmail.com

    James,

    your problem is almost certainly that you didn't put in the list of placeholders in the notes field of your template project. I've attached an example that shows what it should look like.

    Also, you need to set a due or start date for the template project if you want to have date substitution done. It uses the dates you put in the template to compute the adjustments to the date you supply. For your example, I would set the start date of the template project to today, and have that test «ActionName» action have a start date of today. Then when the script runs, it prompts you for the start date, sets the newly created project to start on that date, and goes through filling in the placeholders with the dates adjusted to fit. If your template project started on the 10th, and you had an action starting on the 13th, when it gets to that action it will add 13-10=3 days to the start date of the project you supplied when prompted.

    Reply
  11. jigt@me.com

    Anyone have any input they can provide. I can’t seem to get the Applescript icon in the menu bar even after enabling it in preferences per David’s example. Also, my Library/Scripts folder didn’t have the Applications folder in it. So I created one and one within that for OmniFocus. I then dropped the script inside that folder and added it to my Launchbar index. It seems to work but I want to know if this is the correct way.

    And thanks again to David for a great post!

    Reply
  12. jigt@me.com

    Anyone have any input they can provide. I can’t seem to get the Applescript icon in the menu bar even after enabling it in preferences per David’s example. Also, my Library/Scripts folder didn’t have the Applications folder in it. So I created one and one within that for OmniFocus. I then dropped the script inside that folder and added it to my Launchbar index. It seems to work but I want to know if this is the correct way.

    And thanks again to David for a great post!

    Reply
  13. jigt@me.com

    Anyone have any input they can provide. I can’t seem to get the Applescript icon in the menu bar even after enabling it in preferences per David’s example. Also, my Library/Scripts folder didn’t have the Applications folder in it. So I created one and one within that for OmniFocus. I then dropped the script inside that folder and added it to my Launchbar index. It seems to work but I want to know if this is the correct way.

    And thanks again to David for a great post!

    Reply
  14. jigt@me.com

    Anyone have any input they can provide. I can’t seem to get the Applescript icon in the menu bar even after enabling it in preferences per David’s example. Also, my Library/Scripts folder didn’t have the Applications folder in it. So I created one and one within that for OmniFocus. I then dropped the script inside that folder and added it to my Launchbar index. It seems to work but I want to know if this is the correct way.

    And thanks again to David for a great post!

    Reply
  15. jigt@me.com

    Anyone have any input they can provide. I can’t seem to get the Applescript icon in the menu bar even after enabling it in preferences per David’s example. Also, my Library/Scripts folder didn’t have the Applications folder in it. So I created one and one within that for OmniFocus. I then dropped the script inside that folder and added it to my Launchbar index. It seems to work but I want to know if this is the correct way.

    And thanks again to David for a great post!

    Reply
  16. post@goulbourne.net

    thanks for a fantastic intro (and more) to Omnifocus. I do have a problem with the script – placeholder in OF1.9 on OSX 10.6.7
    I cannot get the script to pick up the names of the variables that I input. The script does produce a new project at the end of my list – but instead of placing eg "New Services" in the placeholder «title», it just copies «title» again.
    I have tried the Snooze script that you recommend in your podcast, and that works well.
    I also tried to replicate your shampooing of Rover, but that threw up the same error. Any ideas on how to sort this out?

    Ian

    Reply
  17. post@goulbourne.net

    thanks for a fantastic intro (and more) to Omnifocus. I do have a problem with the script – placeholder in OF1.9 on OSX 10.6.7
    I cannot get the script to pick up the names of the variables that I input. The script does produce a new project at the end of my list – but instead of placing eg "New Services" in the placeholder «title», it just copies «title» again.
    I have tried the Snooze script that you recommend in your podcast, and that works well.
    I also tried to replicate your shampooing of Rover, but that threw up the same error. Any ideas on how to sort this out?

    Ian

    Reply
  18. post@goulbourne.net

    thanks for a fantastic intro (and more) to Omnifocus. I do have a problem with the script – placeholder in OF1.9 on OSX 10.6.7
    I cannot get the script to pick up the names of the variables that I input. The script does produce a new project at the end of my list – but instead of placing eg "New Services" in the placeholder «title», it just copies «title» again.
    I have tried the Snooze script that you recommend in your podcast, and that works well.
    I also tried to replicate your shampooing of Rover, but that threw up the same error. Any ideas on how to sort this out?

    Ian

    Reply
  19. post@goulbourne.net

    thanks for a fantastic intro (and more) to Omnifocus. I do have a problem with the script – placeholder in OF1.9 on OSX 10.6.7
    I cannot get the script to pick up the names of the variables that I input. The script does produce a new project at the end of my list – but instead of placing eg "New Services" in the placeholder «title», it just copies «title» again.
    I have tried the Snooze script that you recommend in your podcast, and that works well.
    I also tried to replicate your shampooing of Rover, but that threw up the same error. Any ideas on how to sort this out?

    Ian

    Reply
  20. post@goulbourne.net

    thanks for a fantastic intro (and more) to Omnifocus. I do have a problem with the script – placeholder in OF1.9 on OSX 10.6.7
    I cannot get the script to pick up the names of the variables that I input. The script does produce a new project at the end of my list – but instead of placing eg "New Services" in the placeholder «title», it just copies «title» again.
    I have tried the Snooze script that you recommend in your podcast, and that works well.
    I also tried to replicate your shampooing of Rover, but that threw up the same error. Any ideas on how to sort this out?

    Ian

    Reply
  21. whpalmer4+macsparky@gmail.com

    Ian,

    If you are being prompted for the values of the placeholders, but they are not being substituted into the final result, that likely means you have not specified the placeholder names exactly the same in the declaration (in the notes field of the project) and in the usage (or you simply aren't using the placeholders you defined). Whitespace is significant, so «title» and « title » are not equivalent, for example.

    If that still doesn't clear matters up, feel free to send me a PM on the Omni Forum with a copy of your script.

    Reply
  22. whpalmer4+macsparky@gmail.com

    Ian,

    If you are being prompted for the values of the placeholders, but they are not being substituted into the final result, that likely means you have not specified the placeholder names exactly the same in the declaration (in the notes field of the project) and in the usage (or you simply aren't using the placeholders you defined). Whitespace is significant, so «title» and « title » are not equivalent, for example.

    If that still doesn't clear matters up, feel free to send me a PM on the Omni Forum with a copy of your script.

    Reply
  23. whpalmer4+macsparky@gmail.com

    Ian,

    If you are being prompted for the values of the placeholders, but they are not being substituted into the final result, that likely means you have not specified the placeholder names exactly the same in the declaration (in the notes field of the project) and in the usage (or you simply aren't using the placeholders you defined). Whitespace is significant, so «title» and « title » are not equivalent, for example.

    If that still doesn't clear matters up, feel free to send me a PM on the Omni Forum with a copy of your script.

    Reply
  24. whpalmer4+macsparky@gmail.com

    Ian,

    If you are being prompted for the values of the placeholders, but they are not being substituted into the final result, that likely means you have not specified the placeholder names exactly the same in the declaration (in the notes field of the project) and in the usage (or you simply aren't using the placeholders you defined). Whitespace is significant, so «title» and « title » are not equivalent, for example.

    If that still doesn't clear matters up, feel free to send me a PM on the Omni Forum with a copy of your script.

    Reply
  25. whpalmer4+macsparky@gmail.com

    Ian,

    If you are being prompted for the values of the placeholders, but they are not being substituted into the final result, that likely means you have not specified the placeholder names exactly the same in the declaration (in the notes field of the project) and in the usage (or you simply aren't using the placeholders you defined). Whitespace is significant, so «title» and « title » are not equivalent, for example.

    If that still doesn't clear matters up, feel free to send me a PM on the Omni Forum with a copy of your script.

    Reply
  26. Post@Goulbourne.net

    Checked my formatting and all seems fine. Rewrote the project with copy and paste from the declaration – still result the same.
    I can supply HTML version of my project if that would help shed light on this problem – please advise

    Thanks

    Ian

    Reply
  27. Post@Goulbourne.net

    Checked my formatting and all seems fine. Rewrote the project with copy and paste from the declaration – still result the same.
    I can supply HTML version of my project if that would help shed light on this problem – please advise

    Thanks

    Ian

    Reply
  28. Post@Goulbourne.net

    Checked my formatting and all seems fine. Rewrote the project with copy and paste from the declaration – still result the same.
    I can supply HTML version of my project if that would help shed light on this problem – please advise

    Thanks

    Ian

    Reply
  29. Post@Goulbourne.net

    Checked my formatting and all seems fine. Rewrote the project with copy and paste from the declaration – still result the same.
    I can supply HTML version of my project if that would help shed light on this problem – please advise

    Thanks

    Ian

    Reply
  30. Post@Goulbourne.net

    Checked my formatting and all seems fine. Rewrote the project with copy and paste from the declaration – still result the same.
    I can supply HTML version of my project if that would help shed light on this problem – please advise

    Thanks

    Ian

    Reply
  31. Ian Goulbourne

    Problem solved. I tried this script on a synched omnifocus file on my wife's macbookpro. It did not work either – but I caught a glimpse of a notification box that flashed on for a microsecond. There was something about being unable to find growl app.
    So, I installed growl on my iMac and the script works.
    I would suggest to Curtis that he includes a message to the effect that you need Growl – or removes the need for Growl.

    Now really looking forward to pimping my Omnifocus with this script!

    Reply
  32. brandonvault@gmail.com

    I too ran into a problem of NOT being prompted for my custom variable.

    Solution: Change (or just re-type) the values of the

    – property placeholderOpener
    – property placeholderCloser

    within the script.

    Personally I changed my "tags" to "<<<" and ">>>" – for example, "<<<ShowName>>>".

    It was easier to type… and solved my issue.

    Reply
  33. brandonvault@gmail.com

    I too ran into a problem of NOT being prompted for my custom variable.

    Solution: Change (or just re-type) the values of the

    – property placeholderOpener
    – property placeholderCloser

    within the script.

    Personally I changed my "tags" to "<<<" and ">>>" – for example, "<<<ShowName>>>".

    It was easier to type… and solved my issue.

    Reply
  34. brandonvault@gmail.com

    I too ran into a problem of NOT being prompted for my custom variable.

    Solution: Change (or just re-type) the values of the

    – property placeholderOpener
    – property placeholderCloser

    within the script.

    Personally I changed my "tags" to "<<<" and ">>>" – for example, "<<<ShowName>>>".

    It was easier to type… and solved my issue.

    Reply
  35. brandonvault@gmail.com

    I too ran into a problem of NOT being prompted for my custom variable.

    Solution: Change (or just re-type) the values of the

    – property placeholderOpener
    – property placeholderCloser

    within the script.

    Personally I changed my "tags" to "<<<" and ">>>" – for example, "<<<ShowName>>>".

    It was easier to type… and solved my issue.

    Reply
  36. brandonvault@gmail.com

    I too ran into a problem of NOT being prompted for my custom variable.

    Solution: Change (or just re-type) the values of the

    – property placeholderOpener
    – property placeholderCloser

    within the script.

    Personally I changed my "tags" to "<<<" and ">>>" – for example, "<<<ShowName>>>".

    It was easier to type… and solved my issue.

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *