At runtime, when the user is prompted to answer a question (either via chat, a single question or a multi-question dialog), the developer has the ability to provide a default value for any question.
The simplest way to set the default value for a question is to use the question object's editor.
Alternatively, question default values can be set via script, either XpertScript or JavaScript.
The default value for a List, Multi-select List, Date, Boolean or Text question is set using the SetObjectStrProp system function. The first parameter to the function is the question object to be set, the second parameter is the property name and should be entered as "default" and the third parameter is the actual default value.
The default value for a Numeric question is set using the SetObjectNumProp system function.
Question Type | Default Property Value |
---|---|
List | The required default value |
Text | The initial default text |
Boolean | Either the boolean value "true"/"false" or the actual value, for example "Yes"/"No" |
Date | Date in the format of YYYY-MM-DD, for example "2022-07-15" |
Multi-select List | A comma delimited list of required default values |
Numeric | The required default numeric value |
The default can be removed by passing an empty string as the third parameter.
The default question value can be set by calling the prop method on an object, for example...
#Grade.prop("default", "Director"); // List
#Employee.prop("default", "unknown"); // Text
#InLondon.prop("default", true); // Boolean
#TravelDate.prop("default", "2022-07-15"); // Date
#Services.prop("default", "Room,Meals"); // Multi-select
#Cost.prop("default", 42); // Numeric