This doesn’t really tell us much about how you’d like to make/use the link.
To make a link you need two pieces of data:
the selection that you’ll click on
the target of the click: the hyperlink
Where are these two bits coming from? clipboard? selection?
With a bit more detail, perhaps someone could help.
Anyway, it should be something like this:
tell application "DEVONthink Pro"
set URL of attribute run of selected text of tab 1 of think window 1 to "x-devonthink-item://3F2EFA3E-4139-4E5F-88E1-972DEDB6E1F2"
end tell
There is also a simple solution that does not involve scripting. If you right-click in the body of the target document and select ‘Substitutions>Smart Links’, all URLs will be converted to a link after typing them (you need to type the spacebar after entering the URL so that the OS knows to convert the text to a link). You only need to do this once per document-all subsequent URLs will be converted automatically.
Well, here’s an example of what I want to do. This script records the url or item link of each open tab in a window in a rich-text document: ```
tell application “DEVONthink Pro”
set theWindow to front window
set theText to ""
repeat with theTab in (get tabs of theWindow)
if theTab's URL is not "" then
set theLink to theTab's URL
set theSource to theTab's source
set theName to get title of the theSource
else
set theAddress to get uuid of content record of theTab
set theLink to "x-devonthink-item://" & theAddress
set theName to name of content record of theTab
end if
set the theText to theText & return & theName & return & theLink & return
end repeat
create record with {name:"Tab links", type:rtf, rich text:theText} in incoming group
Looking at your code, you are trying to create the link on a plain text string. Strings aren’t rich text, so you’re lost.
I would suggest creating an RTF file with the name of each record and return; then go back and set the URL of the attribute run of each paragraph to the URL or UUID depending on what you want/have.