Rules and automations
Business rules
A rule is bound to a lifecycle event of an entity and compiled to a GoRules decision graph, which the backend evaluates with the zen engine on every matching write. A rule can:
- refuse the write with a validation error,
- set values on the record being written,
- cascade a change to a related record,
- start a workflow.
Rules see the previous value of each column as _previous_<column>, so a rule can fire on
entering a state. A refused update leaves nothing of itself behind: the values it replaced are put
back.
In the Rules and workflows screen, rules are edited as decision tables or as whole decision graphs, and can be tried against a sample record before saving. The dry run answers with the result and the trace of every node.
Automations
An automation is one sentence: when something happens to an entity, only if some conditions hold, then do these steps, in order.
| Step | Does |
|---|---|
| Update a field | Writes one field, on this record or a related one |
| Create a record | Inserts a row and remembers its id for later steps |
| Delete a record | Soft-deletes, so the audit trail still resolves |
| Look up a rule table | Asks a decision table and uses the answer in a later step |
| Work out a value | Sets, copies, adds, subtracts, multiplies or divides |
| Call a web service | Posts to a URL and keeps the response |
Each step that produces something is named, so later steps can use it. Automations built in the application are stored as their own YAML documents.