"Missing value" errors accessing groups

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:

  1. Create a new database named “test”.

  2. Keep it open.

  3. 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.

  1. 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?

  2. 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?

  3. 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?

  4. 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.step 3 -- failure.jpgstep 4 -- success.jpgstep 5 -- success.jpg

You might try:

tell application ID "com.devon-technologies.thinkpro2"
	tell database "Test"
		tell parent "Inbox"
			-- your code goes here
		end tell
	end tell
end tell

Why? Groups are (technically) parents. So if you tell a parent you should be able to do whatever it is you’re doing.

The “incoming group” property returns the desired group:


tell application "DEVONthink Pro"
	return incoming group of database named "Test"
end tell

Well, ok. But why do I get these “missing value” errors against the Inbox, or the Tags or Mobile Sync groups, or sporadically when trying to access any group whatsoever using get record at? And why does the code work, and not work, as I described in detail?

As long as you brought it up, is using get record at to access a database’s Inbox not advised or wrong? Is this behavior “as designed”? If so, where is this documented?

Thanks for the observation korm, but I thought that using get record at was the way to access groups? Am I mistaken? Is there some other way that is guaranteed to work, throw errors appropriately, and consistently?

“get record at” is usually recommended for your own groups whereas properties (like incoming group) are recommended for static groups (as that’s faster and doesn’t depend on names, locations and localizations)

Please, cgrunenberg, answer my question and help me understand:

Why do I get these “missing value” errors against the Inbox, or the Tags or Mobile Sync groups, or sporadically when trying to access any group whatsoever using get record at? And why does the code work, and not work, as I described in detail?

What should I do?

Just to chime in … I’ve spent quite a while testing @Shoolie’s script and different approaches, and I agree – the results are erratic and seemingly random – working then not working. I’d also like to know the answer, since I’ve got several Applescript items in my personal library that use the “get record at …” construct @Shoolie posted, and I’d be interested in whether I need to rewrite them. :confused:

That’s a known issue that will be fixed by the next release.

This snippet is unfortunately buggy, it should look like this:


get record at "/Inbox" in (database named "test")

“tell ” can be used to easily get/set properties. But the command “get record at” uses the current database if the “in” parameter isn’t specified, see documentation.