Skip to main content
Version: 4.64

Dynamic Params

Dynamic Parameters allow values to be passed dynamically to action parameters. They can be used to access data from different contexts, such as forms, database queries, and previous requests.

Dynamic Params are based on evaluables.

Quick guide​

To use Dynamic Params in an action, three properties are required:

PropertyDescription
leadingDelimiterDefines the character sequence marking the beginning of a dynamic parameter.
trailingDelimiterDefines the character sequence marking the end of a dynamic parameter.
dynamicParamsDefines the dynamic parameters and their corresponding evaluables.

The defined delimiters are used within the params object to reference dynamic parameters. When the action is executed, these references are replaced with their evaluated values.

For example, the following action displays the current date and time using a showMessage action:

{
"type": "showMessage",
"leadingDelimiter": "{$",
"trailingDelimiter": "$}",
"dynamicParams": {
"currentDateTime": {
"transform": "formatDate",
"left": {
"context": "date"
},
"right": {
"value": "dd-MM-yyyy HH:mm"
}
}
},
"params": {
"text": "The current date and time is: {$currentDateTime$}"
}
}

In this example, leadingDelimiter and trailingDelimiter define {$ and $} as delimiters.

dynamicParams defines a parameter named currentDateTime. The corresponding evaluable retrieves the current date and time and formats it using formatDate.

The text parameter references the dynamic parameter using {$currentDateTime$}.

When the action is executed, the reference is replaced with the evaluated date and time.

note

The delimiters can be any character sequence. Since the delimiters {{ and }} are used by default in templates and events, it is recommended to use curly braces as the first characters so that dynamic parameters can be easily identified as replaceable.

Using dynamic parameters​

Using form data in a request​

Dynamic Params can be used to access form values and pass them to a request action.

The following example demonstrates a login process with a form containing an e-mail and password field.

When the user triggers the login action, the values are retrieved from the form and passed to an authentication request.

{
"type": "request",
"leadingDelimiter": "{$",
"trailingDelimiter": "$}",
"dynamicParams": {
"email": {
"context": "form",
"field": "email"
},
"password": {
"context": "form",
"field": "password"
}
},
"params": {
"url": "https://example.mobilitysuite.com/authenticate",
"method": "POST",
"contentType": "json",
"post": {
"email": "{$email$}",
"password": "{$password$}"
},
"onSuccessType": "return",
"onSuccess": "result",
"onErrorType": "breakingEvent",
"onError": "loginError"
}
}

In this example, two dynamic parameters, email and password, are defined. Both parameters use the form context to retrieve their respective form field values.

The request references these parameters in the post object.

When the request is executed, the references are replaced with the actual form values.

After a successful request, the authentication token can be saved in the user settings and the app can switch to a different start configuration.

[
{
"type": "setDelimiters",
"params": {
"leadingDelimiter": "{&",
"trailingDelimiter": "&}"
}
},
{
"type": "setValueToUserSetting",
"params": {
"key": "loggedInToken",
"value": "{&result.token&}"
}
},
{
"type": "setCustomStart",
"params": {
"startConfig": "loggedIn",
"switchToCustomStart": true
}
}
]

In this example, the setDelimiters action defines new delimiters for accessing the request result.

The setValueToUserSetting action saves the authentication token in the user setting loggedInToken.

The setCustomStart action switches the app to the loggedIn start configuration.

This allows data retrieved from a request to be processed and reused in subsequent actions.

Reading values from a local database​

Dynamic Params can also be used to retrieve values from a local db_table.

The following example reads the amount of a product from a local database table and saves it in a global variable:

{
"type": "setVariable",
"leadingDelimiter": "{&",
"trailingDelimiter": "&}",
"dynamicParams": {
"amount": {
"context": "query",
"table": "cart",
"query": "getAmountByProductId",
"field": "amount",
"queryParams": [
"42"
]
}
},
"params": {
"variable": "currentAmount",
"value": "{&amount&}"
}
}

In this example, a dynamic parameter named amount is defined. The query context executes the getAmountByProductId query on the local cart table. The field property specifies that the amount field should be retrieved. queryParams passes 42 as a parameter to the query.

The value parameter references the evaluated result using {&amount&}.

The setVariable action stores the retrieved value in the global variable currentAmount.

This approach allows values from local database tables to be retrieved and reused directly within actions.