How I Use OmniFocus to Buy Groceries (Now With More AppleScript)

Even at my least productive, I have always used OmniFocus to organize my shopping lists. Sure, there are simpler, cheaper and more specifically attuned apps out there to help you at the grocery store, but I bought Omni’s GTD app thrice over and I want to get my money’s worth out of it.

A month or two ago I created a “Grocery Shopping” project template which I have been using in conjunction with a few contexts to get my shopping done a tad more efficiently. This past weekend I threw a perspective and an AppleScript into the mix. Basically I’ve taken (almost) every last bit of nuclear firepower hidden within OmniFocus to solve the problem of “why do I always forget to buy X?” Let me show you.

Template Hack

David Sparks wrote the definitive piece on templating OmniFocus projects nearly a year ago. He gives a step-by-step on how to use Curt Clifton’s Populate Template Placeholders script, but that’s overkill for what I need in a grocery list. In this case all we need is a blank project that we can duplicate when needed but is otherwise obscured from view. So here’s what we’ll do:1

  1. Create a new folder called “Templates”.
  2. Create a new Single Actions project in the “Templates” folder called “Grocery Shopping”.
  3. Right click the “Grocery Shopping” project and set it to “On Hold”.
  4. Right click the “Templates” folder and set it to “Dropped”.

Be sure to bring your View Bar up in OmniFocus, as your project and folder will likely disappear once you change their status. Simply set your Project Filter to All Projects and you’ll see your dropped folder and on hold project. In the future we’re going to duplicate the “Grocery Shopping” project and make it an active project.2

Actions All the Way Down

Next we’re going to take advantage of one of OmniFocus’s superb features: action groups. As The Omni Group’s manual puts it, action groups are “useful for keeping track of complicated projects, or breaking actions into smaller actions without creating a whole separate project.”

Grocery shopping isn’t that complicated, but it is relatively easy to break down into smaller actions. In our “Grocery Shopping” project (the one that’s still on hold), we’re going to first create actions for the aisles in the grocery store in the order in which you generally encounter them in the store. My list looks like this:

  • Produce
  • Bakery
  • Deli
  • Meat
  • Pantry
  • Canned Goods
  • Snacks
  • Beverage
  • Dairy

These are organized pretty close to the way I navigate the big grocery stores near me, but your mileage may vary. Reorganize or add to these as necessary.

When it’s time to go grocery shopping, we’re going to duplicate this project and fill in our groceries as “child” actions to these aisle names. To make that easier the next time we start adding groceries, we’re just going to put blank child actions for these aisles. The quickest way to add a child action is to hit return, which creates a new action, then ^⌘→ (control + command + right arrow). Just do that under each action and you’ll eventually have a project that looks like this:

OmniFocus Blank Grocery Shopping Project

Contexts FTW

Now that we’ve got the bones of our project, let’s use some Contexts to flesh it out. Create a “Grocery Store” Context in OmniFocus. I like to keep this nested in a Context called “Errands,” but you can keep it wherever you like.

This next bit may seem like overkill, but I can’t be the only person who prefers to shop at more than one grocery store. I buy most of my food at a big national chain, but the things I really care about (produce, coffee, etc.) I get at a fancy-pants (-ish) health food store. And still some other ingredients I may need to seek out a farmer’s market, or head to the flagship Whole Foods here in Austin, or go to the other big chain here in Texas. All of that is to say I have a context for each store nested in my “Grocery Store” context.

Now, let’s go back to our “Grocery Shopping” project. Select all of the aisles, right click them and set their default context to your top-most “Grocery Store” context. This will make it so that any action you create in this project will be given the “Grocery Store” context. The advantage here is that as you populate all of your aisles with items you need to pick up, they will all show up in your “Grocery Store” context. From there you can look over the list and decide which store you want to get certain items at and move them into place.

The Context Trick

There is some method to the madness of using a context at all beyond micro-managing where you buy bulk granola (as I do). See, your top-level actions, the aisles, won’t show up in your “Grocery Store” context view. You’ll only see the groceries you need listed in aisle order. This is especially useful when syncing with OmniFocus for iPhone.

Here’s a screenshot of my last grocery list in project view on my Mac:

OmniFocus Grocery Shopping Project Mac

And here’s the same list in the “Grocery Store” context on my iPhone:

OmniFocus Grocery Store Context iPhone

On the iPhone I have my view options set to “In Contexts, show: Available” so I don’t see the aisles listed. Now when I’m in the store I just walk from aisle to aisle, ticking off items as I go.

There is one final trick here though.

Calling Up Old Lists

Sometimes I honestly can’t think of a damn thing to buy at the store. Milk? Sure. Crackers? Um, anything else? The best guide for me is usually just my old lists, which should be easy enough to call up after they’re completed in OmniFocus, right? Not exactly.

OmniFocus, for whatever reason, is dreadful when it comes to searching projects by name. It can only search actions by name. The only way around this I could find is Rob Trew’s excellent Find Project Fast AppleScript. Trigger Rob’s script and a dialog box pops up, allowing you to search by project name. It’s impressive, but it takes a few too many steps since what I’m trying to do is repetitive. So I modified the script to open a new window showing completed actions for projects titled “Grocery Shopping”. This is done with the help of a Perspective in OmniFocus, also triggered by the AppleScript.

The first thing you should know about this AppleScript is that, without modification, it will only search for projects named “Grocery Shopping” and change the application’s perspective to “Grocery Lists”. There are instructions in the script itself for how to change those two parameters, but the easiest way to get this up and running is to keep your project and perspective names consistent with mine.

Show your Perspectives inspector in OmniFocus on your Mac by hitting ^⌘P (control + command + P). Create a new perspective called “Grocery Lists”. Set it as laid out in the screenshot below:

OmniFocus Grocery List Perspective

We only want to see completed tasks and projects, organized by completion date. That way when the AppleScript runs you’ll get a brand new window showing all of your old grocery lists with all of the completed tasks (stuff you bought) exposed.

I gave this modified version of Rob’s script a custom icon combining one of Omni’s own perspective icons with one of The Iconfactory’s excellent produce icons. To install it on your OmniFocus toolbar do is the following:

  1. Download
  2. Copy Groceries.scpt to ~/Library/Scripts/Applications/OmniFocus
  3. Right click the OmniFocus toolbar and select “Customize Toolbar…” or go to the menu View > Customize Toolbar…
  4. Drag Script:Groceries to the toolbar

That’s it. Here’s what my the left side of my toolbar looks like now:

OmniFocus Groceries Toolbar Icon

Clicking the Groceries icon pops open a new window. As a semi-bonus, this will actually bring up the on hold Grocery Shopping template, making it a bit easier to duplicate, though there are some inelegant issues with doing it this way (you’ll see).

Next Steps

Okay. That’s a whole lot on how I buy groceries. There’s a bit more to my food workflow I may share another time, but first I’d like to see if anyone out there can help make this workflow a bit simpler.

I’d love to see an AppleScript that takes active tasks from anywhere, even the inbox, and moves them into the appropriate aisle/action group. This way, I can throw food that I’d like to pick up when I have a chance anywhere in my OmniFocus database. For example, I could put “Get Yogurt” in the Inbox, and an AppleScript, or something, could move it to Grocery Shopping > Dairy when triggered.

I don’t know if this is possible, but it would make this list creation even easier and, frankly, would be pretty darn neat.

Now, if you don’t mind, I’ve got some snacks to tend to.

  1. Anything in quotes can be called whatever you like, but to keep things consistent through this demo I’ll be using the terminology I use in my OmniFocus database. ↩︎

  2. You can skip the dropped “Templates” folder if you like and simply keep “Grocery Shopping” as a top level project that is On Hold. I keep it in a dropped folder because I like to check in on my On Hold projects every once in awhile, and I don’t like seeing templates pop up. There are a few other ways to skin this cat but, you know, this is how I do it. ↩︎