Get the name of a note which is applied to an object by applescript

i can’t find in the applescript dictionary the possibility to script the name field of a graphic note. Is that not possible?

thanks pepe

Interesting question.

Release notes for OG 6.0 say “The Notes and Data Inspector now allows unique naming of individual objects.” The name shows up in the List view in the sidebar, which makes it easier to manipulate objects there, but it looks like that’s all it does. As far as I can tell, that name isn’t accessible from Applescript.

Hi @pjuerg - I believe John is correct - however you can use key/value pairs which can accomplish the same thing. You can utilize something like

set X to value of user data value “keygoeshere”

Look for user data value in the dictionary.

We learned this when we created our JTCount script that counts omnigraffle objects. Since we couldn’t key off of “object name” we keyed off of the key/value pairs which are in the space right below the note section in your screenshot.

hi Tyler, that’s a pitty. there is another workaround with the property tag

set tag of objGraphic to “some value”

produces an entry in user data of the objGraph with the key “_tag” {_tag: “some value”}

551 days later, for reference:

Note name: JS .userName() or AS user name property

Note text: AS .notes() or AS notes property

NB: the OmniGraffle GUI may not instantly update when the note or its title are set by script. Close and reopen the inspector to see the refreshed contents.

JavaScript for Automation version

set as shape.userName,
read as shape.userName() (including final pair of parentheses)

function run() {

  var shp = Application('OmniGraffle').windows[0].selection()[0];

  shp.userName = "Now this shape has a name";

  shp.notes = ['and even a few', 'lines of notes', 'as well'].join('\n');

  // check the new values
  return [shp.userName(), shp.notes()]


AppleScript version

on run
  tell application "OmniGraffle"
    tell front window
      set shp to item 1 of (selection as list)
      tell shp
        set user name to "Name of note set through AS"
        set notes to "Note text set through AS"
        -- check the new values
        return {user name, notes}
      end tell
    end tell
  end tell
end run