How do I transfer a variable from input to AppleScript?

objective:

search for DevonThink document using its UUID.

The AppleScript is written by the brilliant DevonThink developer

thanks in advance for your time and help

1 Like

I think your AppleScript should look like:

tell application "Keyboard Maestro Engine"
	set pUUID to getvariable "User_Input"
end tell

tell application id "DNtp"
	set theDoc to get record with uuid pUUID
	open window for record theDoc
end tell
2 Likes

I agree with @rolian

Here is the link to the relevant documentation for getting and setting AppleScript variables: link

1 Like

superb script. Works perfectly. thank you very much. It's very useful.

yes, it works. Thank you for the reference

just for the benefit of other forum members, I would add that your excellent AppleScript opens the DevonThink document in the background. I just had to add the activate DevonThink action after your script

Just to add...

It's general good practice to scope your variables as tightly as possible. So if you used the local variable Local_User_Input in your macro you'd change the AppleScript to:

set theInstance to system attribute "KMINSTANCE"

tell application "Keyboard Maestro Engine"
	set pUUID to getvariable "Local_User_Input" instance theInstance
end tell

tell application id "DNtp"
	set theDoc to get record with uuid pUUID
	open window for record theDoc
end tell
1 Like

thank you