messageBox

Displays a modal messagebox with buttons. The function will return when a button is clicked and return the value, if set, otherwise the title of the clicked button

Parameters

messageBoxOptions - A JSON object with messageBox parameters

Example Usages

let msgBoxResult = await app.messageBox({
  title: "sampel title",
  text: "sampel text",
  buttons: [
    {
      title: "Yes",
      value: "1",
    },
    {
      title: "No",
      value: "0",
    },
    {
      title: "Cancel",
      value: "canceled",
    },
    {
      title: "Demo", // when Demo is clicked it will return "Demo" because the button does not provide a value option.
    },
  ],
});

console.log(msgBoxResult); //This will be either "1", "0", "canceled" or "Demo"
if (msgBoxResult == 1) {
  //enter code
}

Return Values

The messageBox function returns a Promise. The Promise is resolved when a button is pressed in the SmartMessageBox (jQuery plugin) dialog, and it is rejected if no button is pressed or if an error occurs during the process. The resolved value is the value property of the pressed button (if defined), or the title of the pressed button if value is not defined.

Last updated