Scripting advice: focus the created markdown file?

Hi guys, very new to scripting so please ignore potential idiotic questions

I have this AppleScript that takes some info from keyboard maestro and then creates a markdown note:

tell application "Keyboard Maestro Engine"
	set MA_name to getvariable "MA_name"
end tell

-- Create markdown record in specific group

tell application id "DNtp"
	try
		
		set theRecord to create record with {name:MA_name, type:markdown}
		
		-- create a new markdown record
		
		
		#open window for record theRecord -- uncomment if you want to open the new record
		activate
		
		#open window for record theGroup -- uncomment if you want to open the group
		activate
		
	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

i cant figure out how to tell the script to then choose/focus that note so i can paste some content into it. Currently the note is created but not selected.

any clue?

appreciate the help!

Z

tell the script to then choose/focus that note so i can paste some content into it.

This is not how to approach the problem. That’s how a human would do things, not a computer.
Get the clipboard contents and set the contents when you create the record…

set clipData to (get the clipboard)
	create record with {name:MA_name, type:markdown, content:clipData} in current group

PS: Don’t use try.. end try blocks until they’re needed. It masks errors you may have made.

fantastic! Great tip on using clipboard for that. Perfect for my use case

as always a million thanks @BLUEFROG!

Z

You’re welcome