Set Parameter
The Set Parameter element is used to define and set variables (key-value pairs) that can be reused in your workflow using the Expression Language. These variables can be scoped by visibility and persistence to suit your specific needs.
Key Features:
- Visibility Scope: Controls where the parameters are accessible:
- Service: Available across the entire service.
- Block: Limited to a specific block.
- Parent: Limited to the parent component.
- Function: Limited to a specific function. (note: works only with request scope)
- Persistence Scope: Controls how long the parameters persist:
- Request: For the duration of a single request.
- Session: For the duration of the user's session.
- Installation: Persists across the installation's lifecycle.
- User: Linked to the logged-in user.
- Multiple Parameters: Define multiple key-value pairs at once, including nested arrays or objects.
How to Use:
- Select the Visibility Scope and Persistence Scope for the variables.
- Add your parameters in the Properties field as key-value pairs, such as:
trimmed : ${trim(text)}
title : "My Title"
myObject : ${{"key": "value", "other": []}}
- Access the parameters anywhere in your workflow using their key names, e.g.,
${trimmed}.
Example: Creating an Array
Here's how to create a two-dimensional array, such as players[index]["name"]:
- Scope Type:
session
- Properties:
players[0]["name"] : ${"John"}
players[1]["name"] : ${"Jane"}
- Access the array items like this:
${players[0]["name"]} → John
${players[1]["name"]} → Jane
For dynamic arrays where the size isn't predetermined, you can use a counter variable. For example:
- Properties:
players[${counter}]["name"] : ${user.input}