Skip to content

Workflows

A workflow gives the records of a resource a life cycle: states, transitions between them, who may run each transition, tasks and deadlines. The same rules apply in the panel, through the API and on the command line.

draft ──submit──▶ submitted ──approve──▶ approved (locked) ──order──▶ ordered
▲ │
└──submit── rejected ◀──reject──┘
Concept Meaning Details
State where a record is; one per workflow, stored in a column of the record States
Transition a step from one state to another, e.g. approve Transitions
Actor who may run a transition or complete a task Actors
Task work for people: a decision, or one of several approvals in parallel Tasks in parallel, Tasks and inbox
Duration, deadline, forecast how long each step may take, when the case must be finished, when it will probably be finished Durations and deadline
Building block guards, effects, forms and resolvers of the application, by key Building blocks
Tenant configuration per tenant: active or not, who decides, days, optional steps Tenant configuration
  • One state per workflow. Work in parallel (two approvals at once) is modelled with tasks, not with several states.
  • Only transitions change the state. The state column is not part of the form; locked states protect the record from edits.
  • Who decides is data. Actors are permissions, roles, the creator, a person in a field, a resolver of the application, or a slot each tenant configures – optionally released by a second administrator.
  • Definitions are data. They are written in PHP, but the engine runs the data they produce; code is referenced by key. Every version is stored, and running records keep the version they started with.
  • Everything is audited. Every transition, override, completed task and configuration change is in the audit log; the detail page shows the history.
  1. Write the workflow class and attach it to the resource: Getting started.
  2. Add the state column to the table.
  3. Run php spark anvil:workflow:check.
  4. Register Access::pages() in the panel (inbox and workflow settings).
  5. Make the workflow available to tenants and let them activate it, or mark it required().
  6. Schedule php spark anvil:tick every minute (overdue steps, forecasts, reminders).

There is no owner actor, no conditional form and no graphical designer; decision tables, change requests and recertification campaigns are not part of Anvil.