How find and navigate to groups in which a document's replicants are located

Hello, If I am looking at an item in a smart group, it is easy to track the item back to its native group with the reveal in Binder command.
I often find myself in situations where I am looking at a document and want to navigate to the groups where the replicants of that document are located.
All I am able to ascertain at the moment is that a document has replicants because of the change in formatting of the title.
thank you

You can go to the replicants via the Inspector

Or use this script

-- Go to replicants

tell application id "DNtp"
	try
		set theRecords to selected records
		if theRecords = {} or ((count of theRecords) > 1) then error "Please select one record."
		
		set thisRecord to item 1 of theRecords
		if (number of replicants of thisRecord) > 0 then
			set theParents_Names to name of parents of thisRecord whose location does not start with "/Tags/"
			set theParents_Locations to location of parents of thisRecord whose location does not start with "/Tags/"
			set theParents_UUIDs to uuid of parents of thisRecord whose location does not start with "/Tags/"
			set theParentsCount to count theParents_Locations
			set theParents_LocationsAndNames to {}
			
			repeat with i from 1 to theParentsCount
				set thisParent_Name to item i of theParents_Names
				if thisParent_Name contains "/" then set thisParent_Name to my escapeSlash(thisParent_Name)
				set end of theParents_LocationsAndNames to ((item i of theParents_Locations) & thisParent_Name & linefeed & item i of theParents_UUIDs) as string
			end repeat
			
			if theParentsCount > 2 then
				set theParents_LocationsAndNames to {item 1 of theParents_LocationsAndNames} & my sort_list(items 2 thru -1 in theParents_LocationsAndNames)
			end if
			
			set chooseFromListItems to theParents_LocationsAndNames
			set theChoice to choose from list chooseFromListItems with prompt "" default items (item 1 of chooseFromListItems) with title "Replicant Parents" with multiple selections allowed
			if theChoice is false then return
			
			set theChoice_Count to (count theChoice)
			
			if theChoice_Count = 1 then
				set thisParent to (get record with uuid (paragraph 2 of (item 1 of theChoice)))
				if class of think window 1 = viewer window then
					set theWindow to think window 1
					set root of theWindow to thisParent
				else
					set theWindow to open window for record thisParent with force
				end if
				set selection of theWindow to {thisRecord}
			else
				repeat with i from 1 to theChoice_Count
					set thisParent to (get record with uuid (paragraph 2 of (item i of theChoice)))
					set theWindow to open window for record thisParent with force
					set selection of theWindow to {thisRecord}
				end repeat
			end if
			activate
		end if
		
	on error error_message number error_number
		if the error_number is not -128 then display alert "DEVONthink" message error_message as warning
		return
	end try
end tell

on sort_list(theList)
	considering numeric strings
		set theIndexList to {}
		set theSortedList to {}
		repeat (length of theList) times
			set theLowItem to ""
			repeat with a from 1 to (length of theList)
				if a is not in theIndexList then
					set theCurrentItem to item a of theList as text
					if theLowItem is "" then
						set theLowItem to theCurrentItem
						set theLowItemIndex to a
					else if theCurrentItem comes before theLowItem then
						set theLowItem to theCurrentItem
						set theLowItemIndex to a
					end if
				end if
			end repeat
			set end of theSortedList to theLowItem
			set end of theIndexList to theLowItemIndex
		end repeat
	end considering
	return theSortedList
end sort_list

on escapeSlash(theText)
	set d to AppleScript's text item delimiters
	set AppleScript's text item delimiters to "/"
	set theTextItems to every text item of theText
	set AppleScript's text item delimiters to "\\/"
	set theText_escaped to theTextItems as string
	set AppleScript's text item delimiters to d
	return theText_escaped
end escapeSlash
3 Likes

thanks very much !! VERY useful macro.
I created a Keyboard Maestro macro thanks to you.

1 Like

Thanks for sharing this script @pete31, I also find it useful.

It’s definitely faster to invoke the script with a hotkey and then select the group than navigating to replicants via the inspector.

2 Likes

While looking at your screenshot I wonder whether this pop-up menu should be added to the contextual menu of the list/icon/columns view.

I don’t think it’s necessary, if one doesn’t want to use the inspector it’s easy enough to use Tools > Get Info via the shortcut ⌘ + I.

I don’t think it’s a bad idea but I think it’s an uncommon request.