TextExpander Applescript to Retrieve DT3 Data

Correct, just I you, @chrillek, and I have shown.

@BLUEFROG - Any solution anticipated?

No, as (1) the JavaScript support isn’t something we’ve built in, and (2) the AppleScript is functioning as expected.

The support (if it works) is automatic, not built by the developer? (If you support Applescript, Javascript in theory works with no changes?)

How can it be that the same script works for some installations but not others? That seems odd.

Exactly.

So we conclude Apple has basically deprecated or ended support for JXA even though not officially announced?

Not Apple

Devon Technologies

Given that JS should automatically work just like AppleScript, it would be nice if it actually worked reliably. And if a perfectly simple JS works on in some situations but not in others, it would be nice if this fact would receive a bit more attention.

I’m aware that historically AS is dear and near to the heart of many people here. But frankly: It is a dying language. Apple does not do work on it anymore, and outside of the AppleVerse nobody is using it. It is not up to par with any current technology like HT/XML or even old stuff like regular expressions. Even it’s normal text processing capabilities are light years behind, not to mention array methods, introspection, functions as first level citizens. It goes on and on.

On the other hand, JavaScript is the only scripting language available across all Apple platforms. There is no AS support on iOS or iPadOS. So if DT wants to ever provide anything like scripting support on i*OS, it would have to be with JavaScript. Which in turn means that it should become a first class citizen, not relegated to the 2nd or 3rd place.

Yes, I’m aware that Apple has more or less abandoned any development on JXA. On the other hand, it just announced that it’s going to offer shortcuts on MacOS 12. They work cross platform, and they can be programmed with (for example) Scriptable. In JavaScript, no less.

And I’m not advocating to drop AppleScript at all. Just to acknowledge that there is another scripting language available that can do the same things as AS and then some more. It should receive the same support in DT as AS. Just as in Hazel, for example.

Since it now “works” on one Mac DT3 installation but not on others, that suggests to me there might be some workaround possible if we at least knew why that behavior is inconsistent. Maybe it is an Apple issue; maybe it is a DevonTech issue. Do we really know for sure?

In my mind, it works on @BLUEFROG’s and my installation. At least @BLUEFROG got a selection. So it’s 2:1 :wink: But DT would have to investigate this in depth.

We have not deprecated or ended support for JXA.

Do you have any guess what is different about my installation that could cause mine to not work where others do? Anything different I could try?

Might multiple open databases be an issue? The size of the database? What else?

It’s working fine over here too:

(() => {
const app = Application("DEVONthink 3");
const names = app.selectedRecords.name();
var result="";
console.log(names);
names.forEach(n => result += n + "\n");
return result;
})();

Output:

app = Application("DEVONthink 3")
	app.selectedRecords.name()
		--> ["Markdown Test"]

/* Markdown Test */
Ergebnis:
"Markdown Test\n"

Actually, I was getting mostly undefined returns, however… running your code sample in Big Sur…

and…

Maybe because the second script does not return a value at all?

I’m saying the selectedRecords.name() is working, as you have shown (and I confirmed).

However, if you’re just processing selectedRecords() without the property, it’s returning undefined results.

So that leads me to think that from Apple’s perspective it “works.” Arguably from DT3’s perspective too.

What can be different about my setup that is causing a different response that I can try to change? And why the problem with Javascript when the Applescript version works?

Have you rebooted?

Wouldn’t that be funny if that fixed if after all this?

It is on my plan to do this weekend - I rarely reboot on weekdays since the computer operates as a server for others. We shall see if that has any impact when I do it.

A screenshot of DEVONthink’s window showing the selection might be useful.