Workflow overview

The standard Workflow plugin provides everything you need to rapidly develop workflows which help people work together around the information stored in your Haplo application.

All workflow definition and configuration is done by writing code in your plugin. “Point and click” workflow systems are limited by what the authors of the workflow system imagined. By providing carefully designed APIs which enable you to do anything described in code, you can create exactly the workflow you need.

All the Workflow APIs are designed so that the common cases are easy and quick to write, but if you need to do something else, you can override the defaults without having to rewrite any standard functionality.

The Workflow plugin provides workflow features, a mechanism for other plugins to be able to provide additional bits of functionality. The idea is, where something is useful in more than one workflow, it can be implemented in another utility plugin and the code shared. Several standard features are provided.

For user interface showing status and links to the transition UI, the Workflow plugin uses the standard Action Panel plugin.

Using the Workflow plugin

To define a Workflow, you need to create a plugin to implement it and any other functionality associated with it.

The Workflow plugin provides a std:workflow feature which your plugin must use in your plugin.json file.

{
  "pluginName": "example_workflow",
  // ... rest of plugin.json
  "use": ["std:workflow"]
}

Your plugin then creates a new workflow definition and repeatedly calls functions on it to build the workflow.

// Create the workflow definition object
var EgWorkflow = P.workflow.implement("eg", "Example workflow");

// Set the name of the action panel for displaying UI
EgWorkflow.objectElementActionPanelName("example");

// Use a workflow feature
EgWorkflow.use("std:entities:roles");

// Observe entering a state
EgWorkflow.observeEnter({state:"approved"}, function(M) {
    // do something
});

// ...

By convention, an instance of the workflow is named M in plugin code.

Workflows and objects

Workflows are generally associated with a type of StoreObject, although they don’t have to be.

When workflows are associated with objects, more of the user interface will be provided by the Workflow plugin and the platform. It is preferable to use an associated type, as this is an easy way of preserving the historical record.