I have been having no end of problems trying to access groups through script without resorting to manually selecting the group and using selection. When trying to access a group using get record at, I get errors about missing values. So, I decided to write the simplest test script possible to see if I could figure out what I’m doing wrong. I don’t think I’m doing anything wrong, but rather, it looks as though using get record at against groups sometimes works and sometimes does not, and it also shows a problem accessing a database’s default groups. It also appears that getting references to groups is in general problematic.
The simple script below that calls get record at to access a database’s Inbox, Tags group, or Mobile Sync group fails, but succeeds when these groups are renamed, and also succeeds when these groups are renamed back to their original default names. Why?
Try this:
-
Create a new database named “test”.
-
Keep it open.
-
Run this script:
tell application id "com.devon-technologies.thinkpro2"
try
set theGroup to get record at "/Inbox" in (database named "test")
set theName to name of theGroup
display dialog theName
on error error_message number error_number
display alert "DEVONthink Pro" message error_message as warning
end try
end tell
It fails, and throws up the alert: “Can’t get name of missing value.” The AppleScript editor reports:
tell application "DEVONthink Pro"
get record at "/Inbox" in database "test"
--> missing value
display alert "DEVONthink Pro" message "Can’t get name of missing value." as warning
--> {button returned:"OK"}
end tell
Result:
{button returned:"OK"}
Why does the script fail? The group named “Inbox” certainly does exist in the database. To make sure I was using the correct name, I copied the group’s name directly from DTPO and pasted it into the script. It does not work.
-
Rename the Inbox group to Inboxx. Change the script to look for Inboxx. Run the script again. It runs successfully. Why does the script now succeed?
-
Rename the Inboxx group back to Inbox. Change the script to look for “Inbox”. Run the script again. It runs successfully. Why does the script now succeed?
-
Change the script to look for “Tags”. Repeat steps 3 - 5, changing the script accordingly, and renaming the group accordingly. The behavior is the same: the script fails with in step 3, and succeeds in steps 4 and 5. Why?
-
Change the script to look for “Mobile Sync”. Repeat steps 3 - 5, changing the script accordingly, and renaming the group accordingly. The behavior is the same: the script fails with in step 3, and succeeds in steps 4 and 5. Why?
Note: Trying to access any of the default smart groups “All images,” “All PDF Documents,” and “Duplicates” succeeds on the first try, in step 3.
In other scripts, I have only on rare occasion and with no rhyme or reason managed to successfully access any group in any database using get record at. And, scripts that call move to move records from one group to another fail in the same way. There appears to be some problem with references to groups. Any idea what’s going on? I am on DTPO 2.3.5.