How to call SD Notary from AppleScript

I’m trying to run SD Notary via AppleScript, but I’m failing at the most basic thing of creating a document.

This is what I do:

use AppleScript version "2.4" -- Yosemite (10.10) or later
use scripting additions

set the_app to choose file with prompt "Please select an .app to notarize" of type {"com.apple.application"}
set the_settings to {|active identity|:"...", |Apple ID|:"...", |..|:"..."}

tell application "SD Notary"
	--ERROR (translated) can't be converted to type properties of document
	set the_doc to make new document with properties the_settings
	set resultFile to submit app the_doc at the_app
end tell

I feel a bit of a n00b, sorry… What is wrong here?

You can’t define any app’s properties outside a tell block like that (unless you use «class wxyz» style notation).

Hmm, I’m stil sure I’m missing something, because I get the same error with this:

tell application "SD Notary"
	set the_settings2 to make new document with properties ¬
           {|active identity|:"...", |Apple ID|:"..."}
end tell

Get rid of the pipes — they’re forcing the app’s terminology to be ignored, which is exactly what you don’t want.

Ah, right! What put me off was the Dictionary of SD Notary. From the Standard Suite:

FUNCTION SYNTAX
set theResult to make new type class ¬
     with properties record

I still find reading dictionaries a bit troubling…

But a big thanks nonetheless!

How do I add the app password property? If I do it like above (without pipes) I get an Apple Event Error (AEPrint: [0x0,47a47a "SD Notary"]). If I remove app password, it works, but the name of the keychain entry is the default, which I don’t want to change inside SD Notary.

	set newDoc to make new document with properties {allow events:true, Apple ID:"my@mail.com", active identity:"My ID", app password:"MY_PASSWORD"}

When I run this I get a type 6 error. No idea what that is.

tell application "SD Notary"
   try
      set newDoc to make new document with properties {allow events:true, Apple ID:"my@mail.com", active identity:"My ID", app password:"MY_PASSWORD"}
   on error errText number errNum
      display dialog (errNum as text) & return & errText
   end try
end tell

→ Script Debugger 8.0.4 (8A50)
→ MacOS 11.6.4
–>SD Notary 1.4.9 (65)

There’s a bug in setting the app password property. It will be fixed in the next release.

You are probably getting the error because you don’t have a valid entity called My ID. Error 6 is NSArgumentsWrongScriptError, so an invalid value.

1 Like

These issues should have been addressed in version 1.4.10, just released.