TextExpander Applescript to Retrieve DT3 Data

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.

I honestly wouldn’t be surprised but it remains to be seen.


(Clipboard empty also)

Please ZIP and post the JavaScript version you’re showing here. Something looks weird to me.

OK here it is - thanks

Kaplan DT3 JS Test.zip (1.2 KB)

We have not deprecated or ended support for JXA.

We both know that those are deliberately evasive weasel-words.

DEVONTtechnologies has, in fact, unlike other companies, egregiously failed to ensure support and full compliance with JXA use of the osascript interface.

You yourself have often attempted to suggest doubtful but explicit rationalisations for this approach.

In the case of smart action code, DEVONTechnologies has not even pretended to support JavaScript, or to comply with the equal status which Apple itself accords to the two languages which the osascript interface supports.

Exactly as I said, and here I repeat it, the problem does not lie with Apple.

It lies, as you very well know, with DEVONtechnologies.

Of course.

1 Like

You’re using name where it should be name(). These parenthesis are not only meant to amuse @Blanc :wink:

1 Like

Hahaha! Thanks @chrillek

And I have too many screencaps floating around from accessing my M1 Air via VNC.

Here’s an update…

Would you verify this on your side? Thanks!

:+1:
Oops, I didn’t verify anything. Just wanted to let you know that the code is fine (a bit awkward but correct and working)

You’re more the JavaScript wizard than I by a long shot. :slight_smile:
That type of JavaScript for loop is definitely new to me.
Any downside you see in that form?

You mean for n in ...? Well, it’s more what one would use to enumerate the properties of an object. For arrays, I’d go with

array.forEach(element => {
  // Do something with element here
})

That’s more in line with the other array functions like map, filter and reduce. Having a for in loop to get the ‘properties’ of an array (which are just the indices anyway) and then use something like array[property] to get at the elements is a bit contrived.