AppleScript: Parent of record returns tag, not the name of parent group

What are the intended conditions, if any, under which requesting the parent of a record returns one of the assigned tags instead of the actual parent group.

For example in the following scenario:

Screen Shot 2022-10-21 at 11.09.56 AM

use AppleScript version "2.4" -- Yosemite (10.10) or later
use scripting additions

tell application id "DNtp"
	set theSelections to the selection
	if theSelections is {} then
		error localized string "Please select at least one document, then try again."
	end if
	repeat with theRecord in theSelections
		set s to parent of theRecord
		set groupName to name of the first item of parent of theRecord
		-- etc., etc.
	end repeat
end tell

with the record depicted below selected (but not with any of the others), the groupName returns the name of one of the record’s tags, not the parent group name 36.12 SVS. There are no duplicates or replicants. On closer inspection, the parent of that record returns a list of two items. So I suppose the real question is - under what conditions does a record have two (or more) parents?

DTP 3.8.6 | macOS 11.6 | Intel

1 Like
  • An item always has one parent.
  • A tagged item has two or more parents.
  • A replicated item has two or more parents.

If you wanted to filter the tag parents, here is one approach…

In prior versions of DEVONthink it was possible to create new records inside a tag, thus the first parent of such a record was a tag.

Meanwhile if one creates a new record inside a tag then the record really is created in the database’s inbox and the tag is applied afterwards - so it’s not possible anymore to end up with a record who’s first parent is a tag.

So I guess you used a quite old record for testing.

Or just use location group to get the desired group.