This article is outdated, you can access the most current version here: https://doc.onedata.de/apps/apps-docs/odml-documentation/AppBuilder/elements/VariableInputElement.html
All properties in the app can be changed with variables. Variables have the same name as the default properties with a '$' at the front.
If you add a variable to your element you also need to provide the default property without the "$" to reach a valid JSON. This default property can be empty or a fallback value if the resolving of your provided variable fails. If the given variable can be resolved the "Fallback" or default value will be ignored and the element will show the value of the variable. Below is an example:
Article Content
Properties
Property | Type | Description | Example Value |
variables.name | string | Used to set the unique name of the variable | "name": "vars" |
variables.type | string | Used to set the data type of the variable Possible types: "string", "double", "int", "object" | "type": "string" |
variables.default | object | Used to set the preset default values of the variables | "default": { "var1": "Test", "var2": "Test", "colorVal": "green" } |
Variables from Filter values
You can assign the values of filters to variables like this (Example with a Filter Element and a HTML Element. All elements setting filters (tables, charts, filter elements) can be used, though).
The syntax looks like this:
"value": "{{ filters.<id_of_the_element>.<name_of_the_column>.values }}
Syntax for DateTime Picker/Range Filter:
"value": "{{ filters.<id_of_the_elememt>.<name_of_the_column>.valueRange.min }} ||
"value": "{{ filters.<id_of_the_elememt>.<name_of_the_column>.valueRange.max}}
Variable Transformations
Variables can hold complex data structures. To work with them in the various contexts of apps, we have provided a system to transform variables according to your needs. you can apply these transformations by "piping" them after the variable name, e.g.
{{ myvariable.list_of_values | first }}
In this case, we would return the first element of the array stored in myvariable.list_of_values. These variable transformations do also accept options like this:
{{ myvariable.list_of_values | list?separator=;"e=' }}
This would apply the "list" transformation that returns a comma separated list by default. We can set the separator and quote symbol to be used for strings using the options.
See the following table for a list of available transformations and their options:
For the examples, assume the following variables are set:
myFavorites = { "food": ["spaghetti", "pizza"], "number": [23, 66] }
myName = "John Doe"
Transformation | Example Usage | Example Output |
first | "{{ myFavorites.food | first }}" | "spaghetti" |
last | "{{ myFavorites.food | last }}" | "pizza" |
length | "{{ myFavorites.food | length }}" "{{ myName | length }}" | "2" "10" |
json | "{{ myFavorites }}" | "{\"food\":[\"spaghetti\", \"pizza\"], \"number\":[23,66]}" |
list
| "{{ myFavorites.food | list }}" "{{ myFavorites.number | list }}" "{{ myFavorites.number | list?separator=| }}" "{{ myFavorites.food | list?quote=' }}" | "\"spaghetti\", \"pizza\"" "23, 66" "23|66" "'spaghetti', 'pizza'" |
sqlList | ""{{ myFavorites.food | sqlList }}"" | "('spaghetti', 'pizza')" |
upcase | "{{ myName | upcase }}" | "JOHN DOE" |
downcase | "{{ myName | downcase }}" | "john doe" |
You can also chain transformations, e.g.:
{{ myFavorites.food | first | upcase }} => SPAGHETTI
System Variables
Apart from the filter values (see above) that may be available if filters are set, there are also other predefined variables that are always available. See the following table for a list of them:
Name | Description | Example Value |
apps.appSessionId | Unique for each user each time an app is opened (via the list). Refreshing an open app (via F5 / Ctrl+R) does not create a new sessionId. | 12345678-1234-5678-1234-567812345678 |
Example Configuration
Short example of a KPI Element with variables and fallback:
Complete example with KPI variables to change the 'header', 'footer' and the 'value color' of the KPI element with variables:
Was this article helpful?
That’s Great!
Thank you for your feedback
Sorry! We couldn't be helpful
Thank you for your feedback
Feedback sent
We appreciate your effort and will try to fix the article