Outline Item to OmniFocus Task

Those who rely upon computing devices firmly believe that data must be able to be quickly shared between applications and devices. Fortunately, Omni Automation provides a user-enabled mechanism to conveniently move information between apps, such as creating a new OmniFocus task using the information in the selected OmniOutliner item.

Here’s an Omni Automation script for extracting the data from the selected outline row (topic and note) and using it to create a new task in OmniFocus. The script uses the integrated URL support in OmniFocus to create and run a URL link for creating tasks:

items = document.editors[0].selection.items if (items.length === 1){ try{taskName = items[0].topic} catch(err){taskName = ''} try{taskNote = items[0].note} catch(err){taskNote = ''} if(taskName != ''){ taskName = encodeURIComponent(taskName) urlStr = "omnifocus://localhost/add?name=" + taskName if (taskNote != ''){ taskNote = encodeURIComponent(taskNote) urlStr = urlStr + "&" + "note=" + taskNote } URL.fromString(urlStr).open() } }
omnioutliner://localhost/omnijs-run?script=try%7Bitems%20%3D%20document%2Eeditors%5B0%5D%2Eselection%2Eitems%0Aif%20%28items%2Elength%20%3D%3D%3D%201%29%7B%0A%09try%7BtaskName%20%3D%20items%5B0%5D%2Etopic%7D%20catch%28err%29%7BtaskName%20%3D%20%27%27%7D%0A%09try%7BtaskNote%20%3D%20items%5B0%5D%2Enote%7D%20catch%28err%29%7BtaskNote%20%3D%20%27%27%7D%0A%09if%28taskName%20%21%3D%20%27%27%29%7B%0A%09%09taskName%20%3D%20encodeURIComponent%28taskName%29%0A%09%09urlStr%20%3D%20%22omnifocus%3A%2F%2Flocalhost%2Fadd%3Fname%3D%22%20%2B%20taskName%0A%09%09if%20%28taskNote%20%21%3D%20%27%27%29%7B%0A%09%09%09taskNote%20%3D%20encodeURIComponent%28taskNote%29%0A%09%09%09urlStr%20%3D%20urlStr%20%2B%20%22%26%22%20%2B%20%22note%3D%22%20%2B%20taskNote%0A%09%09%7D%0A%09%09URL%2EfromString%28urlStr%29%2Eopen%28%29%0A%09%7D%0A%7D%7Dcatch%28err%29%7Bconsole%2Elog%28err%29%7D

And a version that includes a link-back to the source OmniOutliner item in the note of the created task:

items = document.editors[0].selection.items if (items.length === 1){ try{taskName = items[0].topic} catch(err){taskName = ''} try{taskNote = items[0].note} catch(err){taskNote = ''} itemLink = 'omnioutliner:///open?row=' + items[0].identifier itemLink = encodeURIComponent(itemLink) if(taskName != ''){ taskName = encodeURIComponent(taskName) urlStr = "omnifocus://localhost/add?name=" + taskName if (taskNote != ''){ taskNote = encodeURIComponent(taskNote) urlStr = urlStr + "&" + "note=" + taskNote + "%0A%0A" + itemLink } else { urlStr = urlStr + "&" + "note=" + itemLink } URL.fromString(urlStr).open() } }
omnioutliner://localhost/omnijs-run?script=try%7Bitems%20%3D%20document%2Eeditors%5B0%5D%2Eselection%2Eitems%0Aif%20%28items%2Elength%20%3D%3D%3D%201%29%7B%0A%09try%7BtaskName%20%3D%20items%5B0%5D%2Etopic%7D%20catch%28err%29%7BtaskName%20%3D%20%27%27%7D%0A%09try%7BtaskNote%20%3D%20items%5B0%5D%2Enote%7D%20catch%28err%29%7BtaskNote%20%3D%20%27%27%7D%0A%09itemLink%20%3D%20%27omnioutliner%3A%2F%2F%2Fopen%3Frow%3D%27%20%2B%20items%5B0%5D%2Eidentifier%0A%09itemLink%20%3D%20encodeURIComponent%28itemLink%29%0A%09if%28taskName%20%21%3D%20%27%27%29%7B%0A%09%09taskName%20%3D%20encodeURIComponent%28taskName%29%0A%09%09urlStr%20%3D%20%22omnifocus%3A%2F%2Flocalhost%2Fadd%3Fname%3D%22%20%2B%20taskName%0A%09%09if%20%28taskNote%20%21%3D%20%27%27%29%7B%0A%09%09%09taskNote%20%3D%20encodeURIComponent%28taskNote%29%0A%09%09%09urlStr%20%3D%20urlStr%20%2B%20%22%26%22%20%2B%20%22note%3D%22%20%2B%20taskNote%20%2B%20%22%250A%250A%22%20%2B%20itemLink%0A%09%09%7D%20else%20%7B%0A%09%09%09urlStr%20%3D%20urlStr%20%2B%20%22%26%22%20%2B%20%22note%3D%22%20%2B%20itemLink%0A%09%09%7D%0A%09%09URL%2EfromString%28urlStr%29%2Eopen%28%29%0A%09%7D%0A%7D%7Dcatch%28err%29%7Bconsole%2Elog%28err%29%7D

Solitary Action PlugIn

And with a slight modification, the previous script can be turned into an Omni Automation action that you can install on your macOS and iOS devices:

/*{ "type": "action", "targets": ["omnioutliner"], "author": "Otto Automator", "version": "1.0", "identifier": "com.omni-automation.oo-of.item-to-task" "description": "Script creates a new OmniFocus task from the selected outline item.", "label": "Task from Selected Item", "shortLabel": "Task from Selected Item" }*/ (() => { var action = new PlugIn.Action(function(selection, sender) { // action code // selection options: columns, document, editor, items, nodes, styles selection.items.forEach(function(item){ try{taskName = item.topic} catch(err){taskName = ''} try{taskNote = item.note} catch(err){taskNote = ''} if(taskName != ''){ taskName = encodeURIComponent(taskName) urlStr = "omnifocus://localhost/add?name=" + taskName if (taskNote != ''){ taskNote = encodeURIComponent(taskNote) urlStr = urlStr + "&" + "note=" + taskNote } URL.fromString(urlStr).open() } }) }); action.validate = function(selection, sender) { // validation code // selection options: columns, document, editor, items, nodes, styles return (selection.items.length === 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