This makes no sense. If I want to save the link of the webpage I have open to my inbox, I use the following script, and everything works fine:
tell application "DEVONthink 3"
set theURL to the URL of front window
set theSource to source of front window
set theTitle to get title of theSource
create record with {name:theTitle, type:bookmark, URL:theURL}
end tell
If I want to save the same link to a group I select, the script should surely just be:
tell application "DEVONthink 3"
set theGroup to display group selector "Save link to:" buttons {"Cancel", "OK"}
set theURL to the URL of front window
set theSource to the source of front window
set theTitle to get title of theSource
create record with {name:theTitle, type:bookmark, URL:theURL} in theGroup
end tell
Yet when I try that I get:
Huh? If one works, surely the other should as well. What could possibly be the difference?
If I understand you correctly, you have a web document open in your browser. Then why do you use tell ... DT3 instead of tell Safari (or whatever browser you’re using) to access the front window?
As soon as you use display group selector, DT will be moved to the front (or whatever that behavior is called in macOS). So, your the URL of front window does not go to your browser but to DT (as you tell it to, by the way, and that makes a lot of sense).
Just put the commands to get the data in another tell block, outside of tell … DT3. And then do whatever you want to do with the data in DT.
No, I have the web document open in DT3. The script I use to save the url to my inbox always works. The identical script, but to save to a selected location, does not.
The script references the front window (not "window 1”), because that’s the window I’m looking at. Apparently I should reference something else, but I have no idea what.
Huh. You know what makes it work? Moved this line down to the second-last line:
set theGroup to display group selector "Save link to:" buttons {"Cancel", "OK”}
That’s it. That’s the only change. Why that works and putting it higher up (inside the tell/end tell in both cases) I’ll never know I guess.
So this is the script that works:
tell application "DEVONthink 3"
set theURL to the URL of front window
set theSource to the source of front window
set theTitle to get title of theSource
set theGroup to display group selector "Save link to:" buttons {"Cancel", “OK”}
create record with {name:theTitle, type:bookmark, URL:theURL} in theGroup
end tell
This script might break easily too, just use think window 1 instead of front window. In addition, you should use tell application id "DNtp" to ensure compatibility to other editions/versions.