3

I'm trying to get a simple dialog to show for a workflow I'm working on, but using JXA I keep getting the error: Expecting object specifier, argument has no object specifier. I don't know what to pass in for the object Specifier. My code is below, it takes issue at line 11 where I call the dialog

function run() {

    app = Application.currentApplication();
    app.includeStandardAdditions = true;
    //Error Here
    var who = app.displayDialog('Whose server is this?', {
        withTitle: 'Whose Server...'
    })

    return who
}
richbai90
  • 4,994
  • 4
  • 50
  • 85

2 Answers2

1

Read this unofficial cookbook about User-Interactions, it helps me about these alert things.

In details:

function prompt(text, defaultAnswer) {
  var options = { defaultAnswer: defaultAnswer || '' }
  try {
    return app.displayDialog(text, options).textReturned
  } catch (e) {
    return null
  }
}
Puttin
  • 1,596
  • 23
  • 27
  • ++ for the link and the handy function, but your answer doesn't explain the OP's problem (which is mysterious, given that his code looks perfectly fine). – mklement0 Oct 30 '15 at 03:19
-2

From Gary @ macmost.com https://www.youtube.com/watch?v=GcPUJzmEuKE @ 8:47

app = Application.currentApplication();
app.includeStandardAdditions = true;

color = app.displayDialog("What is your favorite color?", { defaultAnswer: "" }).textReturned;

if (color == "red") {
    app.displayDialog("I like red too!");
} else {
    app.displayDialog("Interesting, I like red myself.");
}