Concepts
Workflows
Graphs of nodes started by a person, a change to an entity or a schedule.
A workflow is a directed graph of nodes without cycles, started by a trigger. Each node is a node type (built in, or from an installed package) with its inputs set. The connections between nodes may have a condition.
How a run moves
A run follows one path:
- It begins at the start and takes the first start connection.
- After each node, it takes the first of that node's connections, in the order they're listed, whose condition holds. A connection without a condition is the else, and must be the last from its node.
- A connection with no target is an end: the run finishes successfully there.
A run also ends, with a note, at a node none of whose connections holds. It fails at the first node that fails, with that node's message.
{
"displayName": "Approve order",
"enabled": true,
"trigger": { "kind": "manual" },
"inputs": [ { "name": "amount", "type": "Decimal", "required": true } ],
"nodes": [
{ "id": "check", "type": "omnicore.set-values", "label": "Check order", "config": { "values": { "total": "{{input.amount}}" } } },
{ "id": "approve", "type": "omnicore.log", "config": { "message": "Approval needed for {{check.values.total}}" } }
],
"edges": [
{ "id": "start", "from": null, "to": "check" },
{ "id": "big", "from": "check", "to": "approve", "condition": "check.values.total > 1000" },
{ "id": "small", "from": "check", "to": null },
{ "id": "done", "from": "approve", "to": null }
]
}Triggers
| Kind | Settings | A run starts with |
|---|---|---|
| Manual | Declared inputs: a name, a field type and whether it's required | The inputs given, checked by type. Started from the designer's Run or POST /api/workflows/{name}/runs. |
| Entity | A perspective; operations (added, updated, deleted); optionally fields, so an update counts only when one of them changes | entityId, perspective, operation, before and after (the perspective's fields), changedFields, changedBy. |
| Schedule | A cron expression with five fields (minute hour day-of-month month day-of-week), in UTC | scheduledAt. Schedules are checked each minute. |
Values
A run's values are input (what it started with) and each node's outputs, by node id. Node settings use them as
placeholders:
{{input.amount}}on its own becomes the value itself, with its type;- inside other text (
Approval needed for {{check.values.total}}), placeholders become text.
Conditions
Conditions use the query language's operators over the run's values:
check.values.total > 1000 & input.vip=, !=, <, <=, >, >=, ~= (contains, ignoring case), &, |, !, parentheses, numbers, 'text',
true, false and null. A value on its own is true unless it's missing, null, false, 0 or empty text.
Checked on every save
A workflow is checked whenever it's saved, and again whenever it's read. It doesn't run while it has problems.
- The trigger is a known kind; an entity trigger's perspective and fields exist, with at least one operation; a schedule parses. Only manual workflows declare inputs.
- Every node type is installed, its settings are inputs of that type, and required inputs are set.
- Connections join existing nodes, there's at least one start, and an else is the last from its place.
- No cycles, and every node can be reached from the start.
- Every condition parses, and every value a condition or setting reads is a start value or the output of a node that can run before that point.
Running
- Four workers run queued runs. Each node has 60 seconds.
- Changes made by nodes are recorded as made by
workflow:<name>, and fire plugins and other workflows one level deeper, up to the same depth limit as plugins, so workflows can't trigger each other forever. - The newest 200 runs of each workflow are kept, each with every step's inputs, outputs, log, error and the connection taken. Runs left unfinished when the server stops are marked failed when it starts.
Who can use workflows
Workflows are for System Admins only: nodes act with full access, as plugins do.
Nodes
The built-in nodes get, find, create, update and delete entities, add perspectives, set values, write to the run's log and fail the run; see Built-in workflow nodes. Developers add their own as C# methods; see Writing workflow nodes.