Opening a DEVONthink document with AppleScript

I’ve managed to create a file in DEVONthink with Applescript:

create record with {name:"New document", content:("content of my document"), type:markdown} in (incoming group of database "Inbox")

Is there any chance to add another script step to display this document in DEVONthink? I would like to accomplish this: create a new document and display the document once it is created.

Not sure whether it was necessary in the past to include root of but this should do it.

I was a bit distracted by content as it’s no property of a record (although it seems to work), so I guess it’s better to use source:

tell application id "DNtp"
	try
		set theNewRecord to create record with {name:"New document", source:("content of my document"), type:markdown} in root of inbox
		open window for record theNewRecord
		activate
		
	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
2 Likes

This works great. Thank you very much.

1 Like