Skip to main content
Version: 4.56

exportTable

Exports one or multiple tables from the app as a JSON file that can be reimported later using the importTable 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" (required)Objectundefinednull
"trailingDelimiter"StringThe trailing mustache delimiter to use.null
"type" (required)StringType name of the action.null

Parameters

KeyTypeDescriptionDefault Value
"async"BooleanSpecifies whether the action should perform asynchronously.null
"fileName"StringThe name of the resulting export file."export.json"
"tables" (required)ArrayNames 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.