Invoking an OF script via URL (macOS)

Is it possible to activate a script inside OF via URL on macOS, passing arguments to it?

There is a workaround available:

  • Add an INBOX item in a specific format via omnifocus:///add
  • Make the script running all the time, polling INBOX, and reacting to it, or maybe activate it via AppleScript

But this is a very roundabout way to achieve the result, and it creates useless trasient INBOX items that, given a bad timing, may also get synced to other devices.

1 Like

Installed plug-ins can be called externally. For example, here is the function for calling a specific action by name:

function performPlugInAction(PlugInID, actionName){
	var aPlugin = PlugIn.find(PlugInID)
	if (aPlugin == null){throw new Error("Plugin is not installed.")}
	var actionNames ={
	if(actionNames.indexOf(actionName) == -1){
		throw new Error("Action “" + actionName + "” is not in the PlugIn.")
	} else {
		} else {
			throw new Error("The action “" + actionName + "” is not valid to run.")
performPlugInAction("com.omni-automation.plugin-id", "nameOfAction")

This function and call can be encoded into a script URL that can be called from other apps or placed in a webpage:


If a plug-in action is designed to process the currently selected items in the app, then it must be adapted to check for the passed selection to be “undefined” and generate the selection object itself. The following example is for OmniOutliner:

	var action = new PlugIn.Action(function(selection){
		// if called externally (from script) generate selection array
		if (typeof selection == 'undefined'){
			// convert nodes into items
			nodes = document.editors[0].selectedNodes
			selectedItems = => {return node.object})
		} else {
			selectedItems = selection.items
		// action code …

Thank you, exactly what I need.

Sal, perhaps a little unkind to users to suggest this degree of inconsistency and wordiness ?

Perhaps worth sticking to a consistent pattern and keeping it simple ? How about just:

.map(action =>


In your second example, you show a quite different but still oddly wordy pattern:

How about just:

selectedItems = => node.object)


In modelling these things, I think there are probably arguments in favour of:

  • consistency
  • simplicity

( Inconsistent and redundant ink is a cognitive cost – a randomly blotted copy book :-)

PS the other thing which seems a bit unneededly techie/hieratic for casual scripters and beginners is:

if(actionNames.indexOf(actionName) == -1)

perhaps simpler to go to the validate() branch if:


and to the error if not ?

.includes seems easier to understand (and type) than the more convoluted and mysterious business of looking for index values of ‘-1’ …

Perhaps worth standardizing on that in sample code ?

(Would make people’s lives a bit easier and less puzzled, I think)

I need to confess that I have tried this numerous times with my placeholder template script and it always fails. As in, OmniFocus crashes. I’m guessing it has something to do with opening the FilePicker.

Is it not possible to simply pass the name of the script? Something like this:


And then have that run it? It seems like encoding and passing the whole bank of javascript is really messy.

1 Like