How to Automatically Flag Starting Tasks in OmniFocus

Bring Scheduled Tasks to Your Attention, Right on Time

OmniFocus lets you track a due date and a start date for each task or project. (In OmniFocus 2, start dates are being rechristened as deferred dates; the behavior is the same.)

Due dates should be used for just that—when the task must be completed, or there will be consequences. Start dates are when the task becomes available—before then, you can’t do anything about it.

I used a two-pages-per-day format when I had a paper planner. Each day had space for you to write the tasks for that day. During weekly planning, you put a task on Thursday, and the task would be waiting when Thursday came.

You can use start dates to schedule OmniFocus tasks for specific dates. With a little bit of scripting, you can have starting tasks automatically show up in the list of what you’re doing today.

Photo courtesy of © iStockphoto/tmcnem

Out of Sight Until You Need It

Scheduling tasks for specific days reduces the number of times you need to think about a task and reduces the chances that you’ll run out of time for it.

For example, my nephew’s birthday is July 28. I want to be sure to buy him a birthday card a week in advance so I have time to sign it and drop it in the mail. I don’t want to buy the card too early, so I don’t have to worry about losing it. I set the due date for July 21 and the start date for July 1.

Without the start date, I might not notice until late July that I need to buy him a card, and now there isn’t much time left. I now have a Buy Card task square in Quadrant 1. With the start date, the task comes on my radar earlier, on July 1, when I have more time to buy the card.

Before July 1, OmniFocus won’t show the task when you’re looking at Next and Available tasks. This reduces the clutter and helps you to focus on tasks you can do something about today.

Unfortunately, OmniFocus doesn’t do much to notify you when a task becomes available. The task will silently appear in your lists. With a little scripting, we can slip them effortlessly into your workflow.

Flagging Starting Tasks with a Script

The following script will flag any tasks whose start/deferred date is today. This causes the task to show up on your list of urgent and important tasks automatically.

Download the script (or copy and paste into AppleScript Editor) and stick it wherever you store your user scripts. (I recommend ~/Library/Scripts).

You can run the script manually, but that’s one more thing to remember to do every day. Let’s do it automatically.

Automatically Flagging Starting Tasks

To automatically flag starting tasks, you can use a LaunchAgent to run OmniFocusDailyMaintenance.scpt every day at 6:00 am.

To install the LaunchAgent:
1. Download the plist (or copy and paste into your favorite text editor).
2. Change username (line 6) to your local user name.
3. Make sure the path to the script (line 10) is correct.
4. Move the plist into ~/Library/LaunchAgents.
5. Load the agent: launchctl load ~/Library/LaunchAgents/OmniFocusDailyMaintenance.plist (or just restart your computer).

You can also change the time the script runs. It should be early in the day, before you’re going to check OmniFocus for the first time. I have the iMac turn on at 6:00 am so it can start getting ready for the day.

If you use start/defer dates to schedule tasks and work from a list of urgent and important tasks (and you should), take a few minutes today to add this script to your setup. It’s a great way to tie the two workflows together and make them work even better.

Question: What’s your favorite way to automate OmniFocus? Share in the comments below! Share your thoughts in the comments, or on Twitter, LinkedIn, or Facebook.

About

Colter writes software and blogs about personal growth and productivity. He lives in Silicon Valley (California) with his wife and children, recently took up golf, and watches mostly British TV shows.

Please note: I reserve the right to delete comments that are offensive or off-topic. For more information, see my comments policy.

  • devyn

    Thank you! I have been a big fan (and heavy user) of your flagged/start methodology (among your other approaches to productivity) for some time, but this…. this… THIS is the missing link!

  • denno

    Thanks-this looks great. I got the error below when I tried to load the agent. My user folder is on a different drive than the boot drive. I put the plist file in ~/Library/LaunchAgents on the boot drive. Thanks for any help.

    JMR-Mac-Pro:~ XXXXX$ launchctl load ~/Library/LaunchAgents/OmniFocusDailyMaintenance.plist

    launchctl: Couldn’t stat(“/Volumes/Macintosh HD/Users/XXXXX/Library/LaunchAgents/OmniFocusDailyMaintenance.plist”): No such file or directory

    nothing found to load

    • I’m sorry I missed your comment until now. I hope you got it sorted out!

  • Sean

    Does this work if there is a space in my username? i.e., First Last

    • Yes, just take out the space. Or just use First. It’s only for organizing jobs and doesn’t need to match anything.

  • iwaddo

    Hi, just looking to install your script to OF2, could I just ask whether the script also flags past defer dates – for example if I did not run the scrip everyday would it still ‘catch-up’ and flag everything when it is next run. Thank you

    • No, the script only flags tasks starting that day. I also use defer dates to track tasks that I want to do “sometime this week” and “sometime this month” (see http://colterreed.com/scheduling-tasks-in-omnifocus/). The script will flag tasks on the first day of the week/month so you can review them, but it will leave them alone after that.

      If you want to flag tasks that were deferred to any day before today, you can change “defer date ? todayDate and defer date < tomorrowDate” to just “defer date < tomorrowDate”.

  • Patricio Anguita

    Colter, thank you for this, works great. I did tweak it a little, like this:

    set todayTasks to (flattened tasks where (defer date ? todayDate and due date is missing value))

    That way I always catch those today-and-past deferred tasks that still don’t have a due date, and if the script does not run any other day the tasks are captured anyway.

    • Interesting twist, considering the presence of a due date.

      Glad you’re finding it useful!

  • iwaddo

    Hi, I have the maintenance script working and so far loving what it is doing for me. Quick question though if I may – when I complete a flagged repeating action it stays flagged and therefore remains in the Today perspective so it seems I have a choice; to either remember to remove the flag from the action before marking it complete or alter the maintenance script to remove all flags first then reapply the flags based on the defer until date. Just wondered what you or others might think and whether anyone else has a tidier solution. Thank you for your help

    • I’ve talked with the OmniFocus team about this exact use case and problem. Basically, there are two use cases for flagged tasks, and OmniFocus supports the one where flagging a task means you’re interested in every repetition of the task (i.e., the flag doesn’t clear when it repeats). Hopefully this will become a preference in a future release.

      In the mean time, if tasks repeat by Defer Another, then the task will be unavailable until its defer until date, so it won’t show up until then anyway. The other two repeat styles (Repeat Every and Due Again) don’t use a defer until date, so the tasks will show up immediately. The simplest thing to do is just clear the flag when you check it off.

      There is one other option, but it takes a little bit of setup: don’t use a repeating task. Instead, write a script that creates a new copy of the task. This is what I do for certain tasks, and the benefit is that I can incorporate the due date into the task title: “Pay August rent”, “Pay September rent”, etc., instead of just “Pay rent”, “Pay rent”, “Pay Rent”, which can be a little confusing. See http://colterreed.com/create-omnifocus-project-templates-with-applescript/ for more information.

      • iwaddo

        Thank you for taking the time to research this and provide a response – for now I think I’m going for the ‘remember to un-flag before completing’ approach and then if I miss one I can simply un-flag it later.

  • Majki

    Hi,

    I am using OF2 since two days and I have already faced this problem: do I need to have the OF2 PRO version to use your script?

  • iwaddo

    Hi, I know your role is not to provide Apple support but I was wondering if I was the only one that was having a problem with the Launch Agent since upgrading to Yosemite – the Apple Scrip seems to work OK if I run it manually but the Launch Agent no longer seems to be launching.

    • iwaddo

      This problem has mysteriously corrected itself following the clock change at the weekend.

      • That’s definitely odd, but I’m glad it’s working again! I was still looking for a likely point of failure after upgrading.

        • iwaddo

          Hi, after two days it has stopped running again and I’ve really no idea why, I hadn’t changed anything when it restarted and I’ve not done anything to cause it to stop, most odd! Any suggestions greatly appreciated.

          • Hmm. Is the computer awake at the scheduled time? If it’s sleeping, it will skip the job.

          • iwaddo

            Hi, yes the computer is waking up, there is an entry in the log. I’ve also changed the wake-up time and script run time to test it, the machine wakes up but the script does not run.

            The script does however run at some point during the day if the mac is on. So far I’ve not worked out any pattern or logic but it is not running at 05:05 as it did everyday prior to Yosemite.

            I’ve download LaunchControl and it shows the script in the list of local agents with the correct execute time.

            Must be a local problem, thank you for your support.

          • iwaddo

            Hi, I still cannot get this to work since the Yosemite upgrade – I’ve a case open with Apple to see if they can assist. Could you please tell me whether you run the launch agent from the system or user folder and it would be great if you could actually send me copies of your launch agent so I can compare with mine – everything works just not at the time it is supposed to. I know this is a local problem so thank you for your continued support.

          • Send me an email, and I’ll see if I can help you figure out where you’re getting hung up. (You can subscribe to my mailing list if you don’t have my email address.)

  • K-Man

    This is exactly what I have been looking for! For whatever reason I can not get the script to do anything. Is this an Omnifocus 2 thing? I do have pro, so scripting does work. Any help with this is appreciated.

    • If you’ve got OmniFocus 2 Pro, you should be good. (It also works with OmniFocus 1.)

      The first thing to check is that the script works when you run it from Script Editor.

      If it does, make sure the script is loaded. After launchctl load path/to/plist, run launchctl list and look for local.username.omnifocus-daily-maintenance. If it’s there, the script is loaded.

      Now see if you can run it manually from launchctl. Create a new task that’s deferred until today. From the command line, launchctl start local.username.omnifocus-daily-maintenance. Tasks starting today should get flagged, just like if you ran the script from Script Editor.

      If that works, then the problem is with the scheduling. Check your StartCalendarInterval and make sure the computer is awake at the scheduled time. I’m not sure what else to check. It runs for me fine on Yosemite (10.10.3).

      Good luck!

      • K-Man

        Hey thank you for the reply. I do have OF2 and I did check straight away if it runs straight from the script editor but it does not. Now I did not modify the script in anyway. Did I miss something or am I not understanding something like needing a specific name on a project or context? Cheers

        • K-Man

          Found my mistake. Works perfectly. I was expecting it to work off of due today not deferred. I admit I’m beyond horrible with these things. I truly appreciate your help and this is a great site you have going here. Cheers

  • Tim

    Hi Coulter, very nice script. Thank you so much. I run it automatically in Keyboard Maestro with a little twist. In my case it removes the flag from a task ones it gets deferred to the future.

    • That’s a good addition. I go back and forth on removing the flag from unavailable tasks. I’m not sure I wouldn’t shoot myself in the foot doing that, so I leave them flagged. But I do like having the Flagged perspective only showing available tasks…

  • Peter

    Hey, I really like the solution Flagging Starting Tasks with a Script after script downloads all goes ok, even more would liked Automatically Starting Tasks Flagging but do not know where I make a mistake, I’m not working. I beg you not know me advice on how I should proceed properly to make everything ok? I have followed your advice, but I do not know, some I do something well adjusted. As should be properly configured the path to script ??? I rewrote the username line 6, line 10 but I’m not sure. After setting the required reboot? or not to be?

    I thank you in advance for your time and look forward to a response, Peter

    • Three things to check:

      1. If you run the script manually (from Script Editor), do tasks with today’s date get flagged? If not, there’s something wrong with the script. Also check by running it from the command line using the script from the launch job.

      2. If you run the kick off the launchd job manually (launchctl start local.username.omnifocus-daily-maintenance), does the script work? If not, then there’s something wrong with the launchd job, and it’s not able to execute the script at all.

      3. If 1 & 2 work, then it’s probably a problem with the job scheduling. You should check out Lingon (https://www.peterborgapps.com/lingon/). It gives you a graphical interface to setting up launchd jobs. You could also use Keyboard Maestro like Tim does. The script just needs to run once a day, before you start your day.

      • Peter

        Hi, thanks for your answer, the first point manually start the script is ok, my job marks flag. How do I manually start point two? (launch job).

        It is my OmniFocusDailyMaintenance.plist in order:

        Label

        local.Aplik.omnifocus-daily-maintenance

        ProgramArguments

        / usr / bin / osascript

        / Users / apps / Library / Application scipts / com.omnigroup.Omnifocus2 / OF DailyMain.scpt

        StartCalendarInterval

        Hour

        06

        minute

        00

        Thank you for answering, Peter

        • It should be: launchctl start local.Aplik.omnifocus-daily-maintenance

  • How would I do an auto-flag for task that have a due date. Let’s say I wanted it to auto flag two days from the due date. I use due dates sparingly but I do use them. I would love to only have my flagged perspective handle this instead of switching back and forth from Forecast to Flagged.

    • Hi, Dan.

      Two options: If you want to script it, you would ask for tasks where due date ? today + 2 * days. But there’s a simpler way.

      You can create a custom perspective that shows tasks that are Flagged or Due Soon. This perspective is my bread and butter. I can see the tasks that are important (I’ve flagged them so I can focus on them today) or urgent (due soon). I go into more detail here: http://colterreed.com/tracking-urgent-and-important-tasks-in-omnifocus/

  • this is excellent!

    I first used the plist your wrote to schedule the app.

    Then I tried a local calendar with the alarm set to “open file” to run the script (saved as an app). This was much easier 🙂

    I then used LaunchControl which is the easiest method of all!

    …Is there an easy way to also remove the defer date so that it no longer shows in the deferred perspective?

    • You should be able to. Where you’re looping over the tasks (lines 12–14), try setting the defer date to missing value.

      Glad you found some easier ways to run it! I was going for something that would work without third-party apps, and be out of the way. I’ll have to check out LaunchControl; looks much easier than creating the plist and running launchctl by hand!