Jump to last used group

This script opens parent 1 of the last added record.

Not sure if that’s useful in your workflow, but as moving a record doesn’t change the modification date of a group this seems to be the nearest you’ll get.

It is a based on Script: Open last added record.

-- Open parent 1 of last added record

tell application id "DNtp"
	try
		set currDate to current date
		set theComparisonDate to currDate - 86400
		
		set theDatabases to databases
		repeat with thisDatabase in theDatabases
			set thisDatabasesResults to search "additionDate >" & theComparisonDate in (root of thisDatabase)
			if thisDatabasesResults ≠ {} then
				repeat with i from (count thisDatabasesResults) to 1 by -1
					set theRecord to item i in thisDatabasesResults
					if type of theRecord is not in {group, smart group} and type of parent 1 of theRecord is not feed then
						set thisDatabasesLastAdded to theRecord
						exit repeat
					end if
				end repeat
				try
					if (addition date of thisDatabasesLastAdded) ≥ theComparisonDate then
						set theComparisonDate to (addition date of thisDatabasesLastAdded)
						set globalLastAdded to thisDatabasesLastAdded
					end if
				end try
			end if
		end repeat
		
		open window for record (parent 1) of globalLastAdded
		activate
		
	on error error_message number error_number
		if the error_number is not -128 then
			display alert "DEVONthink 3" & space & error_number message error_message as warning
		end if
	end try
end tell
1 Like