The TaskContext component lets you set and query the context of a playbook.
Features
Action | Description | Scenarios |
setContext | Sets the context. Note
| Saves contextual information during playbook execution for later use. |
getContext | Queries the context. | Queries saved contextual information. |
appendListContext | Appends a value to a list-type context. Note
| Appends contextual information during playbook execution for later use. |
getListContext | Queries a list-type context. | Queries saved list-type contextual information. |
Configuration example
This topic provides configuration examples for the actions of the TaskContext component. You can import these examples as a test playbook. In the visualization flow editor, you can use the examples to understand and test the parameters for each action. This makes it easy to learn the component's logic and usage. For more information, see Import a playbook.
Save the sample data as a JSON file before you import the playbook.
setContext
Sets a non-list context.
If you execute the action on the same key twice, the second value overwrites the first value.
Parameters
Parameter | Description | Example |
key | The key to set. | k1 |
value | The value to set. Constants, expressions, system parameters, and variable parameters are supported. For more information, see Component parameters and node execution flow. | ${event._tenant_id} |
ttl | The expiration time of the key-value pair, in seconds. Note The default value is 86400 seconds, which is one day. The maximum value cannot exceed 30 days. | 600 |
getContext
Queries a non-list context.
Parameters
Parameter | Description | Example |
key | The key to query. | k1 |
Sample response
{
"value": "ba290292-19a8-4926-9eaa-9a746fc0bd32",
"key": "k1"
}appendListContext
Adds a value to a list-type context.
If you execute the action on the same key twice, the new value is appended to the existing list.
For example, if you execute the action on the same key with the value v1 and then execute it again with the value v2, the value of the key becomes ["v1","v2"].
Parameters
Parameter | Description | Example |
key | The key to set. | k1 |
value | The value to append. Constants, expressions, system parameters, and variable parameters are supported. For more information, see Component parameters and node execution flow. | ${event._tenant_id} |
ttl | The expiration time of the key-value pair, in seconds. Note The default value is 86400 seconds, which is one day. The maximum value cannot exceed 30 days. | 600 |
getListContext
Queries a list-type context.
Parameters
Parameter | Description | Example |
key | The key to query. | k1 |
Sample response
{
"value": [
"4d432034-03ae-4905-a2d8-00237462bc37",
"4d432034-03ae-4905-a2d8-00237462bc37_1"
],
"key": "k1"
}