I’m attempting to use the auto-complete functionality in OmniFocus via JXA. I can do this fine in straight AppleScript:
tell application "OmniFocus"
tell default document
complete "foo" as context span class "match" maximum matches 5
end tell
end tell
If I try similar in JXA, I get the error “Error on line 4: Error: Named parameters must be passed as an object.”
var of = Application("OmniFocus")
of.includeStandardAdditions = true
var doc = of.defaultDocument
doc.complete("foo", {"as": "context", spanClass: "match", maximumMatches:5})
If I exclude the first parameter, I get ‘Error on line 4: Error: Wrong type for “filter”. Should be “NSString”, but got “Document”’. I know this isn’t going to work, but I wanted to see what was going on.
It looks like from the ‘Replies’ log that it’s trying to send the document object as the first parameter on a complete message to the application object:
app = Application("OmniFocus")
app.complete(app.defaultDocument, {maximumMatches:5, as:"context", spanClass:"match"})
--> Error 6: An error occurred.
Anyone any idea what I’m doing wrong?
Thanks,
-A