How to resolve an AppleScript error 1700?

I would lime to read the content of a selected note with AppleScript. Here is the simplified script:


using terms fromapplication "Notes"
  tell application "Notes"
  log selection
  log (count of selection)
  log item 1 of selection
  set theNote to item 1 of selection
  log name of theNote
  end tell
endusing terms from


Unfortunately I get the error message. Here is the log output:


(*selection*)
(*1*)
(*item 1 of selection*)
Result:
error "Notes got an error: Can’t make item 1 of selection into type specifier." number - 1700 from item 1 of selection to specifier

Has someone an idea?

Replies

I don’t think Notes provides a good way to get the selection. If you open its scripting dictionary in Script Editor and search for select, there’s no results.

Oh wait, you’re on 10.15 beta! That does have a

selection
property, but the app’s scripting seems to be having general problems. For example, a simple script like this:
tell application "Notes"
    note 1
end tell

works on 10.14.6 but fails on 10.15 beta. And if you force the issue with this code:

tell application "Notes"
    note 1 of default folder of default account
end tell

you get back a

show
object, not a
note
object. Weird.

I encourage you to file a bug about any such misbehaviour you see.

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"

Thanks for your confirmation. We have posted the feedback FB7074402.