JXA/JavaScript createRecordWith example?

Sorry for the annoying question, after the encouragement to use AppleScript, rather than Javascript for Automation, but I’m close to having precisely what I need in JS.

My issue is that I can use createLocation quite well, but tons of attempts to use createRecordWith() in DTPO fails miserably.

Does someone have an example of a single, successful call?

Otherwise, two questions:

  1. I assume that the named parameter (i.e. “in”) , should be in a second object after the record itself.
  2. Is something like { “name”: “test”, “type”:“markdown”, plainText: “blah blah blah” } sufficient for the record itself?


The automatic AppleScript<>JavaScript bridge doesn’t seem to work in case of the “create record with” command (although the script editor displays it as expected). However, the next maintenance release will support this:

function run() {
    var devon = Application("com.devon-technologies.thinkpro2");
    theRecord = devon.createRecordWith({"name":"Name","type":"markdown","content":"test"})

Thanks, Christian. I assume that by “maintenance release,” you mean general availability (rather than beta)?

Yes, the next public release.

Sadly, your sample code does not work with 2.9.11

It does pop up a group selector, but ultimately returns “null” without creating a document.


Version 2.9.12 is required.

Ack, sorry about that. I had installed the new update, but apparently had two versions of DTPO installed under different names, so the “wrong” one was updated. I, er, stopped doing that.

It would be great from a script developer perspective if there were some logging that we could use. Like a scripting log that would indicate when unimplemented features are requested or untranslatable events or whatnot. It seems like the current signaling is just the return of a “null” whenever anything goes wrong.

I know so little of Apple’s scripting architecture that I can’t even tell if that’s possible, but just a thought. Seeing “null” over and over is somewhat disheartening!

createRecordWith now works, which is greatly appreciated!

You could always use…

tell application id "DNtp"
create record with {name:"test", type:markdown, content:"test"} in current group
end tell