OmniFocus 3 AppleScript Guide

I’ve created a guide to using AppleScript with OmniFocus 3:

I’m sure this is incomplete, so please feel free to submit pull requests.


Obviously I’m new to AppleScript; I made this before learning that AppleScript Dictionaries are things that exist, and that all this info and more is already in the OmniFocus AppleScript Dictionary.

I would say this is a useful adjunct so thank you!

Yes, it’s useful because you included some example syntax and at any rate, I’m sure it helped you learn, too.

Great work! Thanks!

Very helpful! Thanks 😃

You go over how to create a new tag, but how do I add a already existing tag(s) to a task/project? I feel like this should be easy but I’m stuck 😓

set theTask to (first flattened task where its name is "Task Name")
set theTag to (first flattened tag where its name is "Tag Name")
add theTag to tags of theTask
1 Like

Thank you! Appreciate it 😊 One other question: how do you specify a folder (or a subfolder) to put a project/task in?

Hi, hoping for some help even though it is old thread.

Looking to put a task into an existing project.

This is not working, getting an error.

set theProject to first flattened project where its name is "MHProject Name"

Any help would be appreciated.

Assuming you have a project named “MHProject Name”; could you check if this works ?

tell application "OmniFocus"
	tell default document
		set theProject to first flattened project where its name is "This Week"
	end tell
end tell
1 Like

@unlocked2412 much appreciation.

Well, can’t believe it. Getting a working answer in the thread that’s over three years old so quickly.

It helped me to understand that the root object for flattened projects is default document .
Also, I am using Script Debugger and I was able to see that some of my projects had an extra space after the name and that was causing a problem.

Thanks again

1 Like

You’re welcome, @menashehertz