Skip to content

script.prompt ​

Asks the user running the process for a value. Call it in pre(). The answer is available to the rest of the process as a variable with the name you give it.

js
script.prompt(messageToUser, variableName, defaultValue, options)

Parameters ​

ParameterTypeDescription
messageToUserstringThe question to show the user.
variableNamestringThe name of the variable to store the answer in.
defaultValuestringThe value to fill the prompt with.
optionsstring[]Optional. A list of values for the user to choose from.

Examples ​

js
script.prompt("Current Month", "currentMonth", "2014 - Jan");
js
// Ask for a month and a region, then load only that data.
function pre() {
    script.prompt("Month", "month", "2026 - Jan");
    script.prompt("Region", "region", "North", ["North", "South", "East", "West"]);
}

function begin() {
    console.log("Loading " + region + " for " + month);
    script.processUpdateQuery(
        "SELECT * FROM sales" +
        " WHERE month = '" + script.escape(month) + "'" +
        " AND region = '" + script.escape(region) + "'"
    );
}