Outline Item to OmniFocus Project
Using the integrated URL support in OmniFocus , here’s an Omni Automation script for using the data from the selected top-level outline row and its children, to create a new OmniFocus project with actions.
To use the script, simply select a single top-level outline item and run the script. The selected item will be expanded to reveal its children, and all will be copied to the clipboard. Then the script will switch to OmniFocus and paste the copied data into the Projects view, creating a new project for the top-level item, and actions with each of the item’s children.
editor = document.editors[0]
if(editor.selectedNodes.length === 1){
node = editor.selectedNodes[0]
if(node.level === 1){
node.expand(true)
editor.select([node])
editor.select(node.children,true)
editor.copyNodes(editor.selectedNodes, Pasteboard.general)
url = "omnifocus:///paste?target=projects"
URL.fromString(url).open()
}
}
omnioutliner://localhost/omnijs-run?script=try%7Beditor%20%3D%20document%2Eeditors%5B0%5D%0Aif%28editor%2EselectedNodes%2Elength%20%3D%3D%3D%201%29%7B%0A%09node%20%3D%20editor%2EselectedNodes%5B0%5D%0A%09if%28node%2Elevel%20%3D%3D%3D%201%29%7B%0A%09%09node%2Eexpand%28true%29%0A%09%09editor%2Eselect%28%5Bnode%5D%29%0A%09%09editor%2Eselect%28node%2Echildren%2Ctrue%29%0A%09%09editor%2EcopyNodes%28editor%2EselectedNodes%2C%20Pasteboard%2Egeneral%29%0A%09%09url%20%3D%20%22omnifocus%3A%2F%2F%2Fpaste%3Ftarget%3Dprojects%22%0A%09%09URL%2EfromString%28url%29%2Eopen%28%29%0A%09%7D%0A%7D%7Dcatch%28err%29%7Bconsole%2Elog%28err%29%7D
New OmniFocus Project with Selected Item and Children
Copy Script Run Script
01 editor = document .editors [0]
02 if (editor .selectedNodes .length === 1){
03 node = editor .selectedNodes [0]
04 if (node .level === 1){
05 node .expand (true )
06 editor .select ([node ])
07 editor .select (node .children ,true )
08 editor .copyNodes (editor .selectedNodes , Pasteboard .general )
09 url = "omnifocus:///paste?target=projects"
10 URL .fromString (url ).open ()
11 }
12 }
5 Fully expand the row to reveal its children
6 Select the row
7 Expand the selection to include the children
8 Copy the selected items to the clipboard
9 The URL for creating an OmniFocus project. Note the use of the optional “paste” parameter, which will use the contents of the clipboard to generate a new project.
10 Convert the URL string into a URL object and execute it using the open() method
And with a small amount of effort, the script can be adapted to become an installable Omni Automation action:
/*{
"type": "action",
"targets": ["omnioutliner"],
"author": "Otto Automator",
"version": "1.1",
"identifier": "com.omni-automation.oo-of.new-project-with-actions"
"description": "Creates new OmniFocus project from the selected row, and uses row children for project actions.",
"label": "Item to Project",
"shortLabel": "Item to Project"
}*/
(() => {
var action = new PlugIn.Action(function(selection, sender) {
// action code
// selection options: columns, document, editor, items, nodes, styles
node = selection.nodes[0]
editor = selection.editor
node.expand(true)
editor.select([node])
editor.select(node.children,true)
editor.copyNodes(editor.selectedNodes, Pasteboard.general)
url = "omnifocus:///paste?target=projects"
URL.fromString(url).open()
});
action.validate = function(selection, sender) {
// validation code
// selection options: columns, document, editor, items, nodes, styles
return (selection.nodes.length === 1 && selection.nodes[0].level === 1)
};
return action;
})();
Outline Item to OmniFocus Project
Copy Script Install Plug-In
01 /*{
02 "type" : "action" ,
03 "targets" : ["omnioutliner" ],
04 "author" : "Otto Automator" ,
05 "identifier" : "com.omni-automation.oo-of.new-project-with-actions" ,
06 "description" : "Creates new OmniFocus project from the selected row, and uses row children for project actions." ,
07 "version" : "1.0" ,
08 "label" : "Item to Project" ,
09 "shortLabel" : "Item to Project"
10 }*/
11
12 (() => {
13
14 var action = new PlugIn .Action (function (selection , sender ){
15
16
17 node = selection .nodes [0]
18 editor = selection .editor
19 node .expand (true )
20 editor .select ([node ])
21 editor .select (node .children ,true )
22 editor .copyNodes (editor .selectedNodes , Pasteboard .general )
23 url = "omnifocus:///paste?target=projects"
24 URL .fromString (url ).open ()
25 });
26
27 action .validate = function (selection , sender ){
28
29
30 return (selection .nodes .length === 1 && selection .nodes [0].level === 1)
31 };
32
33 return action ;
34 })();
Your browser does not support the video tag.
PLAY
PAUSE
BACK
REWIND
TOPICS
Home
OmniOutliner
Document
Outline
Item
Editor
Style
Text
App-to-App
Item to Task
Item to Project
Document to Task
Slides from Outline
Scripting Dictionary
Action Template
OmniGraffle
OmniPlan
OmniFocus
UNDER CONSTRUCTION
This webpage is in the process of being developed. Any content may change and may not be accurate or complete at this time.
DISCLAIMER
Mention of third-party websites and products is for informational purposes only and constitutes neither an endorsement nor a recommendation. OMNI-AUTOMATION.COM assumes no responsibility with regard to the selection, performance or use of information or products found at third-party websites. OMNI-AUTOMATION.COM provides this only as a convenience to our users. OMNI-AUTOMATION.COM has not tested the information found on these sites and makes no representations regarding its accuracy or reliability. There are risks inherent in the use of any information or products found on the Internet, and OMNI-AUTOMATION.COM assumes no responsibility in this regard. Please understand that a third-party site is independent from OMNI-AUTOMATION.COM and that OMNI-AUTOMATION.COM has no control over the content on that website. Please contact the vendor for additional information.