|
96 | 96 | * [Workflow Constants](#workflow-constants)
|
97 | 97 | * [Workflow Secrets](#workflow-secrets)
|
98 | 98 | * [Workflow Metadata](#workflow-metadata)
|
| 99 | + * [Workflow Context](#workflow-context) |
99 | 100 | - [Extensions](#extensions)
|
100 | 101 | - [Use Cases](#use-cases)
|
101 | 102 | - [Examples](#examples)
|
@@ -6170,6 +6171,44 @@ Some other examples of information that could be recorded in metadata are:
|
6170 | 6171 | - Logging, monitoring, analytics, or audit repository information.
|
6171 | 6172 | - Labels used for organizing/indexing purposes, such as "release" "stable", "track", "daily", etc.
|
6172 | 6173 |
|
| 6174 | +### Workflow Context |
| 6175 | + |
| 6176 | +Similar to [Constants](https://github.com/serverlessworkflow/specification/blob/main/specification.md#workflow-constants) and [Secrets](https://github.com/serverlessworkflow/specification/blob/main/specification.md#workflow-secrets), workflows expressions can have access to the context information of a running instance via the keyword `WORKFLOW`. |
| 6177 | + |
| 6178 | +Implementations may use this keyword to give access to any relevant information of the running instance within an expression. For example: |
| 6179 | + |
| 6180 | +```json |
| 6181 | +
|
| 6182 | +{ |
| 6183 | + "id": "processSalesOrders", |
| 6184 | + "name": "Process Sales Orders", |
| 6185 | + "version": "1.0", |
| 6186 | + "specVersion": "0.8", |
| 6187 | + "start": "MyStartingState", |
| 6188 | + "functions": [{ |
| 6189 | + "name": "myFunction", |
| 6190 | + "operation": "myopenapi.json#myFunction" |
| 6191 | + }], |
| 6192 | + "states":[ |
| 6193 | + { |
| 6194 | + "name":"MyStartingState", |
| 6195 | + "type":"operation", |
| 6196 | + "actions": [{ |
| 6197 | + "functionRef": "myFunction", |
| 6198 | + "args": { |
| 6199 | + "order": "${ .orderId }", |
| 6200 | + "callerId": "${ $WORKFLOW.instanceId }" |
| 6201 | + } |
| 6202 | + }], |
| 6203 | + "end": true |
| 6204 | + }] |
| 6205 | +} |
| 6206 | +``` |
| 6207 | + |
| 6208 | +In this use case, a third-party service may require information from the caller for traceability purposes. |
| 6209 | + |
| 6210 | +The specification doesn't define any specific variable within the `WORKFLOW` bucket, but it's considered a reserved keyword. |
| 6211 | + |
6173 | 6212 | ## Extensions
|
6174 | 6213 |
|
6175 | 6214 | The workflow extension mechanism allows you to enhance your model definitions with additional information useful for
|
|
0 commit comments