Desktop: how to launch OG & a new document?

I have a script that is being generated from a web-app and I want to be able to click a button in a browser and have OG launch and create a new document. I seem to recall it working a while back (I only get time here and there to experiment with automation).

The script works fine now, but it requires graffle to be open to a blank new document. Is there a way around this? I can’t get makeNewAndShow() to do anything, not even the example script from OMNI AUTOMATION.

first line is :
var canvas = document.windows[0].selection.canvas;

Thoughts?

Currently, in the Omni Automation API reference for OmniGraffle (Automation menu > API Reference), the command (method) for creating a new document is in the Document class, not the Application class.

This means that an Omni Automation script is executed within the context of the open document and not the application – so there must be an existing document open.

Document.makeNewAndShow(function(doc){
	cnvs = doc.windows[0].selection.canvas
	cnvs.canvasSizingMode = CanvasSizingMode.Fixed
	cnvs.size = new Size(612,792)
	cnvs.name = "Letter to Sally"
})

You can close the existing document after making the new one:

var oldDoc = document
Document.makeNewAndShow(function(newDoc){
	oldDoc.close()
})

However, this limitation does not exist for the Apple Event languages like AppleScript or JXA (JavaScript for Automation) on macOS.

tell application "OmniGraffle"
	count of documents
end tell

Currently, Omni Automation scripts are not allowed to “see” other documents, even to count how many are open:

app.documents.length
--> TypeError: undefined is not an object (evaluating 'app.documents.length') undefined:1

UPDATE: I checked the website script using OmniGraffle on iOS and it creates a document that appears to be not editable. It must be closed and re-opened to allow for editing. Looks like a bug! Reporting now.