Skip to main content

Conditional steps

Parts of a Flow process can be evaluated conditionally, depending on the value of a predicate, using an if step. It has the following properties:

  • if: the predicate,
  • then: steps that are evaluated in case the predicate is true, and
  • else: steps that are evaluated in case the predicate is false. It is optional.
{
"type": "if",
"if": {
"type": "form_value",
"form": "basic_form",
"participant": "alice",
"scope": "#/properties/optional"
},
"then": {
"type": "sign",
"participant": "alice",
"documents": ["doc1"],
},
"else": {
"type": "sign",
"participant": "alice",
"documents": ["doc2"],
},
}

Predicate

There are three types of predicates: one that has a constant value and two that use results of previously filled-in forms.

Constant value

Constant value predicate is useful mainly for testing. Its value field takes the constant boolean value. For example, to always evaluate the then branch use:

{
"type": "constant",
"value": true
}

Form field has a value

First of the two form-related predicates has a form_value type. It uses a value of a form check-box as the predicate. It takes a participant and a form reference and a JSON Pointer to a boolean form input field.

For example, the following predicate uses the value of an optional check-box in a form labeled basic_form as submitted by the participant alice:

{
"type": "form_value",
"form": "basic_form",
"participant": "alice",
"scope": "#/properties/optional"
}

Form matches a schema

The last predicate type, form_schema_match, takes a form reference and a JSON Schema and checks that the submitted data matches the schema.

For example, the following predicate checks that the participant alice filled-in Correct answer in the question input field of the basic_form form:

{
"type": "form_schema_match",
"form": "basic_form",
"participant": "alice",
"schema": {
"type": "object",
"const": {
"question": "Correct answer"
}
}
}