Here’s the start of the code as now (and the database name was previously within the quotation marks):
(() => {
const app = Application("DEVONthink 3");
app.includeStandardAdditions = true;
const databaseName = "Diaries"; /* Add database name if you want to search for DT records only in this DB */
and here’s the error I still get:
app = Application("DEVONthink 3")
app.database.Diaries.root()
--> Error -1700: Can't convert types.
Result:
Error -1700: Can't convert types.
Stephen
I see. Obviously, it’s a bit more complicated…
Change the following if
if (databaseName !== "") {
/* Get the database record and setup the "in" option for search (see below) */
var DTdatabase = app.database[databaseName].root();
DBOption["in"] = DTdatabase;
}
to
if (databaseName !== "") {
/* Get the database record and setup the "in" option for search (see below) */
const db = app.database[databaseName];
DTdatabase = db.root();
DBOption["in"] = DTdatabase;
}
I’m not quite sure why one would need the additional step, but that seems to work here.
What also works:
if (databaseName !== "") {
/* Get the database record and setup the "in" option for search (see below) */
var DTdatabase = app.database[databaseName].root;
DBOption["in"] = DTdatabase;
}
i.e. the original code without the parenthesis. No idea why, though…
I suspect making everyone else crazy with this thread - but I’m still getting the same error.
The start of the code is now:
(() => {
const app = Application("DEVONthink 3");
app.includeStandardAdditions = true;
const databaseName = "Diaries"; /* Add database name if you want to search for DT records only in this DB */
const DBOption = {} /* Search all databases, otherwise see next if statement */
if (databaseName !== "") {
/* Get the database record and setup the "in" option for search (see below) */
const db = app.database[databaseName];
DTdatabase = db.root();
DBOption["in"] = DTdatabase;
}
and the error:
app = Application("DEVONthink 3")
app.database.Diaries.root()
--> Error -1700: Can't convert types.
Result:
Error -1700: Can't convert types.
Stephen
Insert your favorite swear word <<HERE>>
it must be app.databases[databaseName]
with a trailing s (of course, banging head against wall).
Sorry again.
I didn’t test this part of the code with the rest because I didn’t want to run it through my database. I did test it in Script Editor separately, and there I actually wrote databases
.
<rant>
This is, BTW, another reason why I abhore Apples scripting language: In every other language I know one is taught from the beginning to avoid identifiers that can easily be confused. With AS, it is normal to have “databases”/“database”. And then you get these USELESS error messages. Every other language would tell you “hey the object app
does not have a property/method/whatever database
, go and check again”. Here, you get -1700. Yuck.
</rant>
I laughed out loud! That appears to have effected a major improvement and something now happens. I need to analyse the result but it initially looks very promising. Thanks so much. It may be a little time before I can confirm all is exactly as it should be as I’m a little overwhelmed with things here just at the moment!