Skip to main content
Version: 4.62

askUser

Shows a modal pop-up with buttons in the style of the operating system. The lists of buttons and events or actions reference each other so that the button with a specific index will trigger the corresponding event or action with the same index.

note

If no buttons are defined, an "OK" is displayed by default to confirm and close the modal pop-up.

Field Configurations

KeyTypeDescriptionDefault Value
"params" (required)Objectundefinednull

Parameters

KeyTypeDescriptionDefault Value
"actions"ArrayA list of actions that are fired when the button with the same index is clicked.null
"async"BooleanSpecifies whether the action should perform asynchronously.null
"buttons"ArrayA list of texts that are displayed as buttons.null
"events"ArrayA list of events that are fired when the button with the same index is clicked.null
"isCancelable"Boolean,StringIndicates whether the pop up can be closed by clicking outside the pop up or via the Back button.false
"message"StringThe text of the pop up.null
"onCancel"StringThis event is fired on cancellation.null
"title"StringThe title of the pop up.null

Inherited

From Base Action

Base Action

Field Configurations

KeyTypeDescriptionDefault Value
"dynamicParams"ObjectDynamic params to retrieve data from a specific context e.g. a userSetting.null
"leadingDelimiter"StringThe leading mustache delimiter to use.null
"params"Object,ArrayObject containing the properties of the action.null
"trailingDelimiter"StringThe trailing mustache delimiter to use.null
"type"StringType name of the action.null

Examples

Example 1: AskUser action with multiple buttons and events

Show ExampleHide Example

The button list can contain simple strings or objects with the fields:

  • label: text on the button
  • image: image on the left side of the button

{
"type": "askUser",
"params": {
"title": "$lang(askUser01title)$",
"message": "$lang(askUser01message)$",
"isCancelable": true,
"onCancel": "pickedNothing",
"buttons": [
"$lang(askUser01button01)$",
"$lang(askUser01button02)$"
],
"events": [
"pickedRed",
"pickedBlue"
]
}
}
The app showing the results of the sample code from Example 1.The app showing the results of the sample code from Example 1.

The button with a specific index will trigger the event with the same index.

Example 2: AskUser action with actions

Show ExampleHide Example

The actions are placed in an array of arrays and more than one action can be tied to each button.

{
"type": "askUser",
"params": {
"title": "$lang(askUser02title)$",
"message": "$lang(askUser02message)$",
"actions": [
[
{
"type": "downloadFile",
"params": {
"url": "{{url}}"
}
},
{
"type": "showMessage",
"params": {
"text": "$lang(askUser02actions01)$"
}
}
]
]
}
}
The app showing the results of the sample code from Example 1.The app showing the results of the sample code from Example 1.

If no buttons are specified the askUser action defaults to an "OK" button