Managing Workflow Instances

Once you have your workflow defined, you can create Instances of the workflow.

You will need to create some UI to start the workflow. The Workflow plugin doesn’t provide any UI for this, as each workflow will need to start with a different mechanism.

Once an workflow process is created, you interact with it through a WorkflowInstance object. By convention, use the M variable name.

Definition Instance management interface

Functions are defined on the Workflow definition to start workflow processes and locate existing processes.

function create(properties)

Create a new workflow Instance with the given properties.

If the workflow is associated with an object, properties.object must be that StoreObject.

properties is passed to the start() handler and may contain additional information for your own use.

Returns a WorkflowInstance representing the new process.

function instance(workUnit)

Given a WorkUnit with the correct workType, return a WorkflowInstance representing the process.

Use a WorkUnitQuery to find the relevant WorkUnits.

function instanceForRef(ref)

Given the Ref of the associated object, return a WorkflowInstance representing the process or null if there is no such process.

If you do not have access to the workflow definition object, you can also access the instance using the std:workflow:for_ref service which takes two arguments, workType and ref.


This handler displays confirmation page, and if the user confirm, creates an object representing the task and the workflow instance to go along with it.

P.respond("GET,POST", "/do/example/start-workflow", [
], function(E, project) {
    if(E.request.method === "POST") {
        // Create associated object
        var obj = O.object();
        obj.appendTitle("Example task");;
        // Start workflow and redirect to it
        var M = EgWorkflow.create({object:obj});
        return E.response.redirect(M.url);
        pageTitle: "Start Workflow",
        backLink: "/do/example/task-management"
        text: "Would you like to start a new task?",
        options: [{action:"", label:"Start task"}]
    }, "std:ui:confirm");