exportTable
Exports one or multiple tables from the app as a JSON file that can be reimported later using the importTable action.
Field Configurations
Key | Type | Description | Default Value |
---|---|---|---|
"dynamicParams" | Object | Dynamic params to retrieve data from a specific context e.g. a userSetting. | null |
"leadingDelimiter" | String | The leading mustache delimiter to use. | null |
"params" (required) | Object | undefined | null |
"trailingDelimiter" | String | The trailing mustache delimiter to use. | null |
"type" (required) | String | Type name of the action. | null |
Parameters
Key | Type | Description | Default Value |
---|---|---|---|
"async" | Boolean | Specifies whether the action should perform asynchronously. | null |
"fileName" | String | The name of the resulting export file. | "export.json" |
"tables" (required) | Array | Names of tables to export. | null |
Examples
Example 1: Export multiple tables
Goal: Chose a unique name for the exported file to ensure that it will not be overwritten by a different export. Then export the three tables "favorites", "cart and "settings" from the app in a file and display a success or error message to the user depending on whether the export was successful or not.
main file (i.e. inside a client template)
{
"type": "exportTable",
"leadingDelimiter": "{&",
"trailingDelimiter": "&}",
"dynamicParams": {
"date": {
"left": {
"context": "date"
},
"transform": "formatDate",
"right": "yyyyMMddHHmmss"
}
},
"params": {
"tables": [
"favorites",
"cart",
"settings"
],
"fileName": "Export_{&date&}.json",
"onErrorType": "breakingEvent",
"onError": "dataExportError",
"onSuccessType": "return"
}
}
{
"type": "showMessage",
"params": {
"text": "$lang(exportTableSuccess)$",
"asToast": true
}
}
event/exportTableError.json
{
"name": "exportTableError",
"content": {
"type": "exportTableError",
"actions": [
{
"type": "showMessage",
"params": {
"text": "$lang(exportTableError)$",
"asToast": true
}
}
]
}
}
Result:
An exportTable action has been created.