If a record got no thumbnail then
is undefined, i.e. there’s no (direct) result that could be used.
But we can test whether there’s a thumbnail by using a try
block.
-- Set child groups's thumbnails to selected group's thumbnail
tell application id "DNtp"
try
set theRecords to selected records
repeat with thisRecord in theRecords
set thisRecord_Type to (type of thisRecord) as string
if thisRecord_Type is in {"group", "«constant ****DTgr»"} then
try
-- test whether this selected group got a thumbnail
set thisRecord_Thumbnail to thumbnail of thisRecord as anything
-- set all child groups' thumbnails to this selected group's thumbnail
set (thumbnail of children of thisRecord whose type = group) to thumbnail of thisRecord
on error
-- do something else, e.g. reset child groups' thumbnails
set thisRecord_ChildGroups to (children of thisRecord whose type = group)
repeat with thisChildGroup in thisRecord_ChildGroups
delete thumbnail of thisChildGroup
end repeat
end try
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
return
end try
end tell
This might also be interesting
If you’d like to colorize your groups (or any other record) you could try Script: Colorize DEVONthink Icons.