Setting selection to n records?

Hi, is it possible to set the selection of a viewer window to n records?

Tried but got errors with “vector”. I then tried to work around by first getting the uuid (and getting the record afterwards), but no matter what I tried, again errors with “vector”.

What are you referring to by vector ??

Why are you trying to get some number of records in a viewer window?


I stumbled over this every now and the, but still have no idea what this error means.

Would be very handy to automatically set the selection, e.g. to group records or script testing

The script throws the error on this line

set selectRecords to sel & thisRecord

property targetSelectionCount : 5

tell application id "DNtp"
		set win to viewer window 1
		set theGroup to root of win
		set theRecords to children of theGroup
		repeat with thisRecord in theRecords
			set sel to selection of win
			set selCount to count of sel
			if selCount < targetSelectionCount then
				set selectRecords to sel & thisRecord -- error "vector"
				set selection of win to selectRecords
				exit repeat
			end if
		end repeat
	on error error_message number error_number
		if the error_number is not -128 then display alert "DEVONthink" message error_message as warning
	end try
end tell

@cgrunenberg would have to respond about the vector error, but in general, you usually shouldn’t look to automate things like this in the interface. It’s usually fragile and inconsistent, or requires a lot of exception handling.

It’s just a type error – it works without error if you make sure that both operands of & are lists:

set selectRecords to sel & {thisRecord}

(Not sure, of course, whether the effect is what you are aiming for)

That’s it. Thanks a lot!

1 Like