Workflow — Developer Index

Entry point for the Enezaframework workflow developer guides. Start here, then follow the links to the topic you need.

Table of Contents

  1. What the Workflow Guides Cover
  2. The Four Features
  3. Documentation Map
  4. Suggested Reading Paths
  5. A Note on Testing

What the Workflow Guides Cover

enezaworkflowengine is the workflow approval engine of Enezaframework. Documents are submitted into approval workflows, condition steps decide routing, and saved queries define which records match a condition.

These guides cover four supporting features of that engine:

  • The Workflow Type Registry, which maps a workflow name to the models its condition queries may use.
  • The Workflow Query Enhancements, which add object-scoped query execution and aggregate annotations to SavedQuery.
  • The State-Based Workflow, which runs a document through developer-defined states with user-chosen transitions and parallel Fork/Join branches.
  • The Workflow Hooks, which run developer business logic after approval and state-based engine events.

Who this is for: Django developers and coding agents extending the workflow engine or wiring workflow conditions into a business app.


The Four Features

Feature What it does Entry doc
Workflow Type Registry Maps each Workflownames value to allowed query-builder models, with framework defaults, project overrides, and runtime registration. Workflow Type Registry Architecture
Workflow Query Enhancements Adds object_id filtering so condition queries are scoped to one document, and annotations so filters can use SUM/COUNT/AVG/MIN/MAX over related models. Workflow Query Architecture
State-Based Workflow Runs a document through user-defined states (workflow_kind='state_based'), with actor-chosen transitions and parallel Fork/Join branches alongside the approval engine. State-Based Workflows
Workflow Hooks Runs developer callables after workflow events (submitted, approved, state_entered, ...) for both the approval and state-based engines. Workflow Hooks
flowchart LR
    subgraph Registry["Workflow Type Registry"]
        R1[Framework defaults]
        R2[Project workflowconfig/]
        R3[Runtime register()]
        R1 --> R4[WorkflowTypeRegistry]
        R2 --> R4
        R3 --> R4
        R4 --> R5[QueryBuilderMixin]
        R5 --> R6[Query builder UI]
    end

    subgraph Query["Workflow Query Enhancements"]
        Q1[SavedQuery.get_queryset]
        Q1 --> Q2[object_id filtering]
        Q1 --> Q3[annotations -> annotate]
        Q3 --> Q4[aggregate filters]
        Q2 --> Q5[Workflow engine condition steps]
        Q4 --> Q5
    end

    subgraph State["State-Based Workflow"]
        S1[WorkflowTemplate.workflow_kind = state_based]
        S1 --> S2[Designer: state / fork / join graph]
        S2 --> S3[StateTransition + StepTemplate]
        S3 --> S4[state_workflow engine -> WorkflowBranch]
        S4 --> S5[Document.workflowstate]
    end

    subgraph Hooks["Workflow Hooks"]
        H1[WorkflowTypeConfig.WORKFLOW_HOOKS]
        H3[Engine events] --> H4[emit_workflow_event -> on_commit]
        H4 --> H2[WorkflowHookRegistry]
        H1 --> H2
        H2 --> H5[handler context]
    end

    R6 -. saved queries .-> Q1

Documentation Map

Pos Guide What it covers
1 Workflow — Developer Index This page — feature map and navigation.
2 Workflow Type Registry Architecture Components, merge logic, and first-request data flow.
3 Workflow Type Registry Quick Start Built-in workflow types and using the generic query builder.
4 Workflow Model Configuration The model config dict, relationships, and the full schema.
5 Workflow Project Configuration The workflowconfig/ package, settings, and merge behavior.
6 QueryBuilderMixin Integration How generic views resolve workflow names and models.
7 Workflow Dynamic Registration register(), has_workflow(), get_allowed_models().
8 Workflow Type Registry Examples Override, extend, and register workflows.
9 Workflow Type Registry Troubleshooting Common misconfigurations and fixes.
10 Workflow Type Registry Reference API, settings, and files.
11 Workflow Query Architecture SavedQuery.get_queryset, annotation parsing, and auto-extraction.
12 Workflow Query Quick Start An aggregate-enabled query and object-scoped execution.
13 Workflow Object ID Filtering Scoping query results to a single document.
14 Workflow Aggregate Annotations parse_annotations() and aggregate filter rules.
15 Workflow Query JSON Format Rules-style and groups-style formats with annotations.
16 Workflow Query View Integration BuildQueryView, SaveQueryView, and SaveQueryDetailView.
17 Workflow Engine Auto-Extraction How condition steps supply object_id.
18 Workflow Aggregate Metadata API get_aggregate_options() for the builder UI.
19 Workflow Query Error Handling Validation errors, Django errors, and fallback behavior.
20 Workflow Query Examples Aggregate + object-id examples, including SQL equivalents.
21 Workflow Query Reference APIs, schemas, edge cases, and files.
22 State-Based Workflows User-defined states, transitions and parallel Fork/Join branches as a second workflow kind.
23 State-Based Workflow Architecture Components, data model, runtime lifecycle, fork/join internals and the designer pipeline.
24 State-Based Workflow Reference Choices, model fields, service APIs, rules S1–S20, design_data schema, URLs, commands and errors.
25 State-Based Workflow Troubleshooting Symptom → cause → diagnostic → fix for stuck, invisible or unassigned state workflows.
26 Workflow Hooks Developer extension points, the 9 events, registration, after-commit execution and sync/async.
27 Workflow Hooks Reference Event table, WorkflowHookContext, filters, ordering, settings, check_workflow_hooks and troubleshooting.

The original, unsplit references remain available at workflow-type-registry-developer-guide.md and workflow-query-enhancements-developer-guide.md.

For surrounding framework concepts, see the Enezaframework developer index:


Suggested Reading Paths

Adding a workflow type to a project 1. Workflow Type Registry Architecture 2. Workflow Model Configuration 3. Workflow Project Configuration

Registering a workflow type from an app 1. Workflow Dynamic Registration 2. Workflow Model Configuration 3. QueryBuilderMixin Integration

Scoping conditions to a document 1. Workflow Query Architecture 2. Workflow Object ID Filtering 3. Workflow Engine Auto-Extraction

Writing aggregate conditions 1. Workflow Aggregate Annotations 2. Workflow Query JSON Format 3. Workflow Query Examples

Building a user-defined state workflow with parallel branches 1. State-Based Workflows 2. State-Based Workflow Architecture 3. State-Based Workflow Reference 4. State-Based Workflow Troubleshooting

Running business logic on workflow events 1. Workflow Hooks 2. Workflow Hooks Reference 3. Workflow Project Configuration


A Note on Testing

Per project rules, the developer or agent does not run or claim test results. The user is solely responsible for all testing and validation of the output described in these guides.