Openexternally parameter not working

I read with interest of the new parameters openexternally and app that could be appended to an x-devonthink-item:// link.

However I find that they’re not working within DEVONthink documents, and will only work in some other apps.

For instance, this link:

x-devonthink-item://36621996-4BC6-4BDC-A82F-B27C38C99136?openexternally=1&app=Scapple

… will not work from within a link in an RTF file in DEVONthink (it just reveals the document in DEVONthink), yet if I paste it into BBEdit and choose that app’s Open URL contextual menu selection, the link opens the item in Scapple.

But this link:

x-devonthink-item://D78A676D-547C-42BF-AF78-C293317066FB?openexternally&app=TextEdit

… won’t open from a link in a DEVONthink document, nor from a link in any other app. (in all cases it just reveals the document in DEVONthink)

This behaviour doesn’t seem affected by toggling the Double-click opens documents externally or Click on links opens them externally preferences.

So it seems a bit hit and miss, unless I’m missing something obvious.

It’s actually only intended for item links used in other applications so far.

I see! I hope its use is extended to work within DEVONthink, as that would be useful.

But like I say, in the case of external apps, it works in some and not in others. No idea why.

What kind of use case do you have in mind?

Any examples?

The use case of, say, keeping ‘monitoring’ notes to a larger document that I’m working on. Those notes contain links to other files somewhere in DEVONthink. It would be good to be able to open some of those links in one app and some in another (i.e., not always the OS’s ‘default’).

Ah, sorry, I worded that badly. What I meant was, “links for certain external apps”. That is, appending certain apps in the link (like TextEdit), doesn’t work in external apps. So, for example, using BBEdit’s ‘Open URL’ contextual menu selection:

x-devonthink-item://36621996-4BC6-4BDC-A82F-B27C38C99136?openexternally=1&app=Scapple

… opens the item in Scapple. But (still using BBEdit’s ‘Open URL’ contextual menu selection):

x-devonthink-item://D78A676D-547C-42BF-AF78-C293317066FB?openexternally&app=TextEdit

… does not open the item in TextEdit (it opens in a new DEVONthink window).

vs

You are missing =1 in the second example. Is that a typo in the post or the problem?

2 Likes

Omg. Creeps off with tail between legs. Where’s my coffee?

1 Like

I’m just making some :slight_smile: Drop by any time :slight_smile:

And no worries - I didn’t see it in your original post either :see_no_evil:

2 Likes

And I suppose once you’ve copied an item link, you could use an AppleScript something like the one below to put the ‘external app link’ in the clipboard, ready to paste into the external app, as that app’s link:

set theData to (the clipboard as text)
set the clipboard to (get (the clipboard) & "?openexternally=1&app=")
set anApp to choose application with title "Choose app:"
set appName to name of anApp
set the clipboard to (get (the clipboard) & appName)
set x to (get (the clipboard))
set the clipboard to (my findReplace(text 1 thru -1 of x, " ", "%20"))
on findReplace(t, toFind, toReplace)
set {tid, text item delimiters} to {text item delimiters, toFind}
set t to text items of t
set text item delimiters to toReplace
set t to t as text
set text item delimiters to tid
return t
end findReplace
set d to (get (the clipboard))
display dialog d with title "Copied"

If you cancel out of the app choice dialog, the resulting link will still open the linked file in the default app you’ve set in macOS for that file type.