Skip to content

Instantly share code, notes, and snippets.

@doug4j
Created January 1, 2019 17:16
Show Gist options
  • Save doug4j/5fc27ddb926b19a71f939f0c855988d3 to your computer and use it in GitHub Desktop.
Save doug4j/5fc27ddb926b19a71f939f0c855988d3 to your computer and use it in GitHub Desktop.
var projName = "My First Auto-created Project";
var app = Application("Omnifocus")
app.includeStandardAdditions = true
var doc = app.defaultDocument
var matchingProjects = doc.flattenedProjects.whose({name: projName})
var theProject = null
if (matchingProjects.length == 0) {
theProject = app.Project({
name: projName,
status: 'active'
})
doc.projects.push(theProject)
app.displayDialog("Created new project")
} else {
theProject = matchingProjects[0]
app.displayDialog("Reused existing project")
}
//theProject is now set (whether created new or reading from match)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment