Created
January 1, 2019 17:16
-
-
Save doug4j/5fc27ddb926b19a71f939f0c855988d3 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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