Create workflow Definition
Workflows are implemented in their own plugin, using the framework in the standard Workflow plugin.
1) Install Workflow plugin
Ensure that the std_workflow plugin is installed.
2) Create a new plugin
It’s best if workflows, and any directly associated UI, are implemented in their own plugin.
First, you must use the std:workflow feature in your plugin.json file:
{
"pluginName": "example_workflow",
// ... rest of plugin.json
"use": ["std:workflow"]
}
3) Implement Definition object
Your plugin then creates a new workflow definition and repeatedly calls functions on it to build the workflow.
var EgWorkflow = P.workflow.implement("eg", "Example workflow");
By convention, use a name which describes your workflow, with the suffix Workflow, for example, ProjectApprovalWorkflow.
In this documentation, we’ll use EgWorkflow to represent the definition object.
function P.workflow.implement(name, readableName)
This function returns a new Workflow Definition object, which implements the API described in this section.
name is the name of the workflow, which will be prefixed by your plugin name. It’s passed to workUnit() when the underlying WorkUnit object is defined.
readableName is the human readable name of the process, used in the UI.
4) Configure Definition object
To build up the workflow,
- Define states
- Include the standard features useful for your workflow, and any other features from plugins providing workflow components
- Set the text for your user interface