Nesting URL into URL-scheme to share OmniFocus tasks

I’m trying to nest an OmniFocus URL-scheme into a DTTG URL-scheme, so I can share OmniFocus tasks over DT including multiple OF fields like due date, projectname, tags etc.

Manually pasting the OF URL-scheme into a DT bookmark works fine, but I run into a problem when automating it with a DT URL-scheme.

I’ve URL encoded the OF task, replacing &, ? and = signs with their corresponding hex numbers, but it doesn’t work as expected.

x-devonthink://createbookmark?location=omnifocus:///add%3Fname=Call%20Jim&title=Call%20Jim

This adds a bookmark with the title Call Jim and a bookmark to omnifocus:///add?name, but the following text is blank. So when I click it, OmniFocus is opened, but (as expected) the title field is empty. Replacing the second equal with %3D also doesn’t work. Anyone got an idea?

It appears such constructions aren’t supported.

The bigger question is: Why are you going to call me?? :thinking: :stuck_out_tongue:

1 Like

Well to ask you how to nest a url in a url, but I kept forgetting to call you without the task in my to-do list :slight_smile:

I’ve managed to get one simple task imported. I’m not sure why it worked that one time as I experimented further and didn’t get it working again sadly (to many concurrent changes… I know, I shoudn’t have done that)

1 Like

You could probably script this. In AppleScript, creating a DEVONthink bookmark with a given URL would be something like:

create record with {name:"Some Task", URL:"omnifocus:///add?Some&20task", type:bookmark}

If you need to use iOS, OmniFocus supports JavaScript automation, so it may be possible to build something for both platforms.

Thanks! I’ll give it a try.

The idea is to export an OF task in iOS to DTTG and reimport it with another iOS device by clicking on the bookmark. I’ve already managed to do that manually by using the share sheet in OF and having Shortcuts extract the OF task, exchange task with add and copy that to the clipboard. When I paste that URL-scheme in the DT bookmark as a proof of concept, it works flawlessly.

Also nesting a DT URL-scheme into an OF task works fine, i.e. the other way around. Might you have OF running, the link below creates a task and adds the DTTG URL-scheme to the notes, which you can click to add the bookmark to DTTG:

omnifocus:///add?name=Read%20NY%20Times&note=x-devonthink://createbookmark?location%3Dhttp%253A%252F%252Fwww.nytimes.com%26title%3DNew%2520York%2520Times

That’s why I’m somewhat boggled why nesting an OF URL in the DT URL-scheme only seems to work partly (the omnifocus:///add?name is added, but the rest isn’t).

It appears such constructions aren’t supported.

Update, as they appear to be somewhat supported. I’m one step closer to the solution, but I get the idea there might be a bug in DTTG.

If I append this URL-encoded OmniFocus URL-scheme

omnifocus%3A%2F%2F%2Fadd%3Fname%3DCall%2520Jim%26note%3Dx-devonthink-item%3A%2F%2FUUID%26context%3DCommunicate%26tags%3DCall

to this DT URL scheme

x-devonthink://createbookmark?location=

I end up with

x-devonthink://createbookmark?location=omnifocus%3A%2F%2F%2Fadd%3Fname%3DCall%2520Jim%26note%3Dx-devonthink-item%3A%2F%2FUUID%26context%3DCommunicate%26tags%3DCall

Which creates a bookmark called ‘Unnamed’ with a URL-scheme that opens OmniFocus as expected, and displays a new a task “Call Jim” with a tag called ‘Call’ and a DT UUID in the notes. The project ‘Communicate’ is missing though.

Strangely, when I add parameters such as ?title, it either stops working or adds ‘?title’ literally as an OmniFocus tag. Perhaps @cgrunenberg has an idea?

(BTW: I still haven’t called :slight_smile: )

1 Like

I think I resolved it:

  • the context parameter of the OF URL-scheme needs to be exchanged with project for the Project field to get filled in OF
  • I incorrectly used &?title= instead of &title= in the DT URL

With the following URL you can automatically create a DT bookmark, that will subsequently create an OmniFocus task with the title “Call Jim”, the tag “Call” in the project “Communicate” when clicked on in DT.

x-devonthink://createbookmark?location=omnifocus%3A%2F%2F%2Fadd%3Fname%3DCall%2520Jim%26note%3Dx-devonthink-item%3A%2F%2FUUID%26project%3DCommunicate%26tags%3DCall&title=Call%20Jim

I’ll do some testing further up the road, but it seems to be possible to automate the creation of a repository of clickable OF task in DT using Shortcuts.

As it is also possible to export OmniFocus tasks with Shortcuts the workflow for multiple users could become:

  • User A creates a complex task in (personal) OF
  • User A exports the task to a DT bookmark
  • User A syncs DT database
  • User B syncs database
  • User B clicks the DT bookmark
  • User B adds the complex task to (personal) OF

Of course it’s also possible to set more static OF templates this way.

(Paradoxically, now I found a working solution there is no need to call @BLUEFROG anymore, so I’ve dropped that task).

1 Like