OmniFocus and Workflow - Dictionary Simplicity

For the past couple of years, I’ve used an AppleScript on the Mac to template birthday projects in OmniFocus. I had a set of tokens in OmniFocus task notes which described how the AppleScript should run, which would then import the templated project back into OmniFocus. The downside of this approach was that I needed to be on the Mac to clear the reminder task for each birthday.

With the advent of the task share button in OmniFocus 3, I decided to translate the process to Workflow. Importing my note tokens, I ended up with quite a long workflow before I’d even arrived at the main flow… Then, I noticed the Get Dictionary from Input action and I realised that I could get straight to the properties if I formatted the note tokens as a JSON dictionary.

Setup

  1. Use a Workflow Action Extension
  2. Get Item from List - Get: First Item
  3. Match Text - Pattern: \{.*\}
  4. Get Dictionary from Input
  5. Set Variable

I’m not fully sure if the dictionary needs to be saved as a variable but it seemed to make it simpler to access later. You can then use the dictionary and its values where you would use other variables or inputs by entering the placeholder and then tapping on it to type in the key you want to use.

Caveats

  • The JSON dictionary can be the only place you should use curly braces {} in your OmniFocus reminder task.
  • Beware of smart quotes when formatting the JSON dictionary. I used Drafts and later TextExpander to make sure I kept straight quotes.
  • The keys on a Workflow dictionary are hand typed on each use. Make sure you get them right or you won’t get the value you expect.

Use

  1. Add a JSON dictionary to the notes of an OmniFocus 3 task.
    Example:
    {"name":"Great Aunty Beryl","birthday":"19/09","gift":"yes","deliver":"no"}
  2. When the task becomes active, select it, tap the share button and run your Workflow.
  3. Watch your Workflow run and do whatever you’ve told it to.

The Benefits of Using OmniFocus as a WorkFlow Trigger

  • You do not need to leave OmniFocus to act on your Workflow task.
  • You can maintain a set of reminders (in my case, birthdays) and avoid a ton of repeating projects… Less for your weekly review.
  • Pre-fill your Workflow fields and inputs for repeating tasks.

I hope this post sparks new ideas for ways Workflows can be used. My Workflow can be found here: OmniFocus Birthday but be aware that it’s designed for my OmniFocus setup. If you think the birthday date in the dictionary looks odd, it’s because I’m British. Any date formatting will unique to your locale and I could have also used month names in this case, just miss out the year as Workflow fills that for us.

Thanks for reading.

6 Likes

This is interesting – what are you doing with Get First Item and the regular expression? It seems like you’re separating out the different things that OF shares out, but I’m bad at regex :slight_smile:

Hi Matthew,
You are right. OmniFocus sends five pieces of information from the task. The first two are text in html format. The next is data (perhaps any attachments?), the forth is a link to the original task and the fifth is the task encoded as a url scheme.
Regex is something I also want to learn but decided that is was the quickest way to get the text I needed from the task so looked around the web for cheat sheets. I was looking for the text between and including the curly braces. The back slashes escape the braces because they are part of the Regex syntax.
\{ - match open curly brace.
.* - match any characters.
\}- match closing curly brace.

1 Like

Thanks for sharing, I love seeing regex patterns broken down because it just takes time to learn them and put what’s happening in context. I just haven’t been back in OmniFocus lately so I haven’t experimented with their changes.

Even quick & dirty patterns can be super helpful for personal use cases and less all-in-one tools.

I use Replace Text in a very sloppy way and sometimes Split Text on a custom character to achieve my basic needs so far, which works until I finally do more with Regex.

1 Like