Workflow Expressions
Last updated
Last updated
Workflow model parameters can use expressions to select/manipulate workflow and/or state data.
Note that different data filters play a big role as to which parts of the states data are to be used when the expression is evaluated. Reference the section for more information about state data filters.
By default, all workflow expressions should be defined using the syntax. You can find more information on jq in its .
Serverless Workflow does not mandate the use of jq and it's possible to use an expression language of your choice with the restriction that a single one must be used for all expressions in a workflow definition. If a different expression language needs to be used, make sure to set the workflow expressionLang
property to identify it to runtime implementations.
Note that using a non-default expression language could lower the portability of your workflow definitions across multiple container/cloud platforms.
All workflow expressions in this document, as well as are written using the default jq syntax.
Workflow expressions have the following format:
Where expression
can be either an in-line expression, or a reference to a defined expression function definition.
To reference a defined expression function definition the expression must have the following format, for example:
Where fn
is the namespace of the defined expression functions and myExprName
is the unique expression function name.
To show some expression examples, let's say we have the following state data:
In our workflow model we can define our reusable expression function:
We will get back to this function definition in just a bit, but now let's take a look at using an inline expression that sets an input parameter inside an action for example:
In this case our input parameter applicantName
would be set to "John Doe".
Expressions can also be used to select and manipulate state data, this is in particularly useful for state data filters.
For example let's use another inline expression:
This would set the data output of the particular state to:
We can now get back to our previously defined "IsAdultApplicant" expression function and reference it:
For example let's say that we have a workflow data input of:
we can use this expression in the workflow "version" parameter:
which would set the workflow version to "1.0.0". Note that the workflow "name" property value is not allowed to use an expression. The workflow definition "name" must be a constant value.
require for expressions to be resolved to a boolean value (true
/false
).
As previously mentioned, expressions are evaluated against certain subsets of data. For example the parameters
param of the can evaluate expressions only against the data that is available to the it belongs to. One thing to note here are the top-level parameters. Expressions defined in them can only be evaluated against the initial .