Drafts Scripting Reference

Prompt

Prompts allow the creation and display of custom dialogs.

Properties

Functions

Class Functions

Examples

var p = Prompt.create();

p.title = "Hello";
p.message = "World!";

p.addTextField("textFieldName", "Label", "");

p.addDatePicker("myDate", "Start date", new Date(), {
  "mode": "date"
});
p.addButton("First");
p.addButton("Second");

var didSelect = p.show();

var textFieldContents = p.fieldValues["textFieldName"];
var startDate = p.fieldValues["myDate"];

if (p.buttonPressed == "First") {
  // do something
}