Testing OmniGraffle 7.3's built-in JavaScript automation

Hi, OmniGraffle automators!

Are you comfortable programming in JavaScript? Are you comfortable testing early builds? We just shipped our first public test builds of OmniGraffle 7.3 for Mac, which implements most of what we think is needed to get started with automating the app using JavaScript. (The upcoming OmniGraffle 3 for iOS will also include the same support, but it’s not quite ready for TestFlight yet.)

You can download the latest build here:

And when you have that build installed and open, you can use this link to enable its JavaScript support:

  • omnigraffle:///change-preference?OJSEnabled=true

You might need to restart the app at that point to get it to notice the changed setting, but once you’ve done that there will be a new Scripts menu with commands like Show Console and Documentation.

The built-in documentation is very bare bones right now, but Sal Soghoian is putting together a website that goes into a lot more depth about how to actually use the scripting environment (with sample code, etc.). You’ll find it over at omni-automation.com.

Also, you can select some shapes on a canvas and use Edit > Copy As > JavaScript to get some code which creates those shapes. However, be forewarned that I just found three bugs in the code it created (all easy enough to work around, but definitely something we want to fix before all this ships). [EDIT: These bugs are now fixed, so I removed the extra details describing how to work around them.] If you notice any other bugs, please don’t hesitate to report them.

And if you have any questions, please don’t hesitate to ask! The sooner we hear from you, the sooner we’ll be able to figure out how best to improve what we’re building.

P.S. — The latest test builds of OmniOutliner 5 have similar support, which can be enabled in much the same manner:

  • omnioutliner:///change-preference?OJSEnabled=true

Delighted to see Copy As Javascript and all the related developments appearing in the test builds !

Not sure what the preferred approach to running the activation url is – it worked well here with a Terminal command line:

open omnigraffle:///change-preference?OJSEnabled=true

(The safari URL field didn’t respond to it on this system)


Are the videos on the omni-automation site all silent, or do they have audio tracks which my browser is failing to find ?

Greetings. Most of the videos that demonstrate a specific function will only have the sound of clicks or taps. The longer tutorial-style videos that are under-construction will include narration. Cheers! – SAL


Excellent project, and delighted to see your involvement in it :-)

Sorry, I forgot that Discourse doesn’t let me link to app URLs. I’ve made those URLs plain text now (rather than nonfunctioning links), and you should be able to simply copy and paste them into the location field of your web browser.

1 Like

The need for automation is universal, and so it is immensely gratifying to see an iOS app respond to scripts the way macOS apps do! Kudos to the Omni Group for having the insight and determination to make this a reality.


The bugs that I listed yesterday for Edit > Copy As > JavaScript are now fixed. Please let us know if you encounter any others!

1 Like

Just updated the example plugin to include a new library: CanvasLib

// Call libraries like this:
aPlugin = PlugIn.find(“com.NyhthawkProductions.OmniGraffle”)
canvasLib = aPlugin.library(“CanvasLib”)

// get a list of the library’s handlers

// get a bit of documentation about the library’s handlers


Added examples of Alert() to online documentation: https://omni-automation.com/shared-alert.html

Sensational job Omni team! I am very excited with the introduction of scripting function in OmniGraffle with javascript (aka OmniJS). I have referred to the documentation and played with it a bit and I think I’ve got a handle on the basic direction you’re taking thus far:

1.) The ability to manually launch the OmniJS terminal window and enter code on-the-fly.
2.) The ability to develop functions as libraries in downloadable/installable plugins.

Suggestions for some amazing enhancements:

1.) When I had the beta installed I think the menu for the terminal at the top was “scripts” or scripting". Just name it OmniJS -it would look sweeter.
2.) You have Stenciltown for your community of stencils. This might be a good time to register a domain to start a community surrounding the incredible extensibility of OmniJS. Hmmm, looks like somebody beat me to the punch to acquire omnijs.com. Darn it.
3) It would be extraordinary for those of us in the print industry to have a way to do a glorified mail-merge via javascript into OmniGraffle. Could you please have your team bake in textReplace into omniJS? I know you can identify textboxes in OmniGraffle…let me replace that text with a self-developed data source (aka plaintext CSV or some other delimited format) so I can script a merge and export the resulting document in the various file types you support.
4) Closer to launch, please add auto-completion to the OmniJS terminal window.
5) The ability to save the script entered into the terminal.
6) Some basic debugging would be nice. Basically anything a traditional JS developer would need I’d appreciate in OmniJS.

i found this implementation extremely interesting using Swift. But I’ll keep on eye on both the OmniJS and Swift fronts to accomplish what I want.

Thanks for the consideration.


The ability to embed OmniJS in links and URLs is another important feature as well. Web-based documentation and data sharing become really useful. More will be revealed.-- SAL


New documentation on the Alert() object. https://omni-automation.com/shared-alert.html



1 Like

And if you have any questions, please don’t hesitate to ask!

Will JXA (JavaScript for Automation) scripts developed in Script Editor “just work” in OmniJS too?


We’d love to have things be familiar to people who are already using JXA to script our apps, but there are certainly differences. The scripting model we’re building is designed to work on iOS as well as Mac, whereas JXA is designed around Mac-only Apple Events.

(The good news is that OmniJS scripts are not only cross-platform, they’re also much much faster than Apple-Event-based scripts.)

1 Like

Thanks. I was guessing there might have to be differences. Can you give a simple (specific if possible) example of a difference we might commonly encounter when doing relatively straightforward scripting of the app (in my case OmniOutliner) itself?

I don’t want to spend too much time getting down in the weeds now with JXA if the differences might turn out to be substantial. I do like the possibilities of cross-platform!


Maybe a tiny bit off topic - though I don’t think so. :-)

Will the x-callback-url support on iOS evolve to match the capabilities of OmniJS? Personally I’m most interested in OmniFocus but using OmniGraffle also I’d love this to be the case there. I can think of plenty of diagram generation scenarios in my (shockingly misnamed) :-) “day job”.


Reposing my question above on differences between JXA and OmniJS:

Would appreciate any light that can be shed on this.



The most obvious difference between JXA and OmniJS is the “Every…Whose” clause support in Apple Events is not in core JavaScript. The result is that scripts must have iteration routines using for… and forEach… to locate the desired objects.

Also, in most Apple Events implementations, you can address an object by index or name. The name addressor is not supported in core JavaScript.

But these differences shouldn’t hinder you in creating very useful and powerful OmniJS scripts. Myself, I use script templates to quickly insert the routines I use often :-) – SAL

Not quite the same thing, but check out this page http://omni-automation.com/shared/url-app-to-app.html about App-to-App communication (under construction). OmniJS scripts can execute scripts targeting other Omni apps and then process the results of the calling script.

1 Like