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

 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; })();
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