BPMN Workflows

SINCE VERSION 1.0 DRAFT

What is a BPMN Workflow?

A workflow in PIPEFORCE is a stateful business process, where one or more humans are involved. Workflows can be modelled using a graphical interface and they can optionally trigger the execution of pipelines.

Workflow design with BPMN

In PIPEFORCE, workflows can be designed using BPMN (Business Process Model and Notation), which is a worldwide ISO standardization to describe business processes in a formalized (graphical) way. Also, most non-technicals can understand BPMN diagrams. If you’re not familiar with BPMN so far, we highly recommend you to learn more about it before you dive deeper into this chapter. Here you can find a first introduction on Wikipedia: https://en.wikipedia.org/wiki/Business_Process_Model_and_Notation .

Below is a very simple example of such a BPMN diagram, which shows a vacation approval process where the employee must fill-out a request form, and the supervisor can then approve or decline the vacation request:

BPMN digrams are designed using a BPMN designer tool. You can use your own local software to design such a diagram and then upload them to PIPEFORCE, or you can use the built-in online BPMN designer from PIPEFORCE. With the latter, you can:

  • Create BPMN diagrams online in your web browser and save them

  • Discuss a BPMN diagram with your team

  • Link BPMN tasks with pipeline

  • Directly execute and review BPMN diagrams as workflows

In order to draw a BPMN diagram, the most important elements are these, that you should be aware of:

User Task

The user task is the part of a workflow in case an input from a user is required. The workflow waits at this point until the user has finished this task by clicking “Complete”.

The input of the user is typically given by filling-out a form.

The form can be defined using the “Forms” tab in the modeller.

Note: The input in the form fields have a length limit of 4000 characters

User tasks can also be assigned in the workflow to specific users and user groups, by using the general tab. This can be done in the "Assignment" section below the "Description" field. You have to fill out these fields for this: Assignee, Candidate Users, and Candidate Groups. Here, multiple users and user groups can also be given by adding commmas in between their user-names and group-names respectively.

System Task

If a task in the workflow must be executed by a “machine”, for example, sending an email, doing a conversion, or creating a new dataset, typically a System Task is used for this.

By default, a pipeline is used to execute such a system task.

To configure a system task to execute such a pipeline, you need to make sure, that you have these settings in place:

  1. The task type is set to a System Task.

  2. The Implementation is set to Delegate Expression.

  3. The Delegate Expression is set to ${pipelineDelegate}.

To execute a pipeline, you have two configuration options:

  1. Calling a pipeline embedded into the User task as a parameter.

  2. Calling a pipeline stored in the property store.

Call an embedded pipeline

In order to trigger an embedded pipeline whenever the system task is executed, you can define a new input parameter with the name pipeline of type Text, and add the pipeline directly as a value:

Call a pipeline stored in the property store

Lets assume, a pipeline is stored in the property store under this key path:

global/app/vacation-request/pipeline/myPipeline

Then, you need to configure your System Task like this to automatically pick-up and execute this pipeline, in case the system task is executed by the workflow:

  1. Make sure the Id of the BPMN workflow has the same name as the app: vacation-request.

  2. Make sure the Id of the System Task, which should execute the pipeline, has the same name as the pipeline: myPipeline.

  3. Do not define any pipeline parameter in the System Task.

When executed, the System Task automatically searches for a pipeline in the given app folder and executes it.

How to start a workflow in PIPEFORCE?

The design and execution of a workflow in PIPEFORCE is always a 3-steps task:

  1. Design the workflow in the BPMN modeler, and save the result. When you work locally with the pi tool, save it at: app/myApp/workflow/myWorkflow.bpmn.

  2. Deploy by pushing the DEPLOY button in the online designer, or upload the BPMN file using the pi tool by calling the command: pi publish.

  3. Execute the workflow using the command workflow.start in a pipeline, and set the Id of your process as the parameter key (see BPMN file). You can use, for example, the pi tool to start a workflow:
    pi uri ”workflow.start?key=<ID>”

Then, you can login to your portal at https://<NAMESPACE>.pipeforce.net, and complete the workflow.

How to create a trigger pipeline

A pipeline, executed when an app is started, is called a trigger pipeline. Each pipeline is written in YAML format.

  1. This pipeline listens to the new form entry.

  2. Sets the variables

  3. Maps the form data to workflow model (workflow data).

  4. Perform different operations on file / directories if needed.

  5. Save the data in variables, which we can use later in our next steps / pipelines.

Let's create a simple trigger pipeline:

1. Headers

The headers section is optional in our trigger pipeline. It is used to configure any global variable which is used to execute the pipeline e.g. description of the pipeline, auto execute pipelines, manage versions, user authorization, etc. Headers can be used in pipeline like following:

headers: description: "A010 listens for a new form entry, maps form data to workflow model + starts the workflow"

Note: To get more details regarding this feature, please see: Headers

2. Vars

This section is also optional in our trigger pipeline. This helps to initialize the variables and set those variables later in the other steps in the same pipeline.

vars: workflowModelInstanceKey: null # To be set by the workflow when calling this pipeline workflowModel: "#{@property.lazy(vars.workflowModelInstanceKey)}"

3. Pipeline

Pipeline section is mandatory for execution of any application. It includes all the commands which are executed in the sequential order. We use the Pipeline Expression Language (PEL) to write the expressions in pipeline. Scope of pipeline is defined as follows:

  1. Listen to events:

    Every time an event is fired after matching the given criteria, all commands after the event.listen, will be executed. It executes commands like creation of property, copy property, delete property, error handling on login, etc. For example, creation of a new property store every time the pipeline is executed.

    Note: To get more details regarding this feature, please see: Events

  2. Capture the data:

    Data, which is entered in start form entry, is captured and converted into the required format e.g. converting the form values (object) into a map.

    Note: To get more details regarding this feature, please see: Convert

  3. Initialize the variables: Set the values of variables and update / save them e.g.

  4. Manage attachments: It helps to manage files / attachments uploaded from the entry-form and save them to a particular path / directory. Here is the bifurcated example to do this task:

    1. Create Directory / Folder

      Note: To get more details regarding this feature, please see: drive.archive.save

      Here, to create a directory, we need to run the pipeline as the system user, because only that user has the folder creation rights.

    2. Get Attachment and Get Content

      Get file from entry-form and save into a variable

      Get content of file

      Note: To get more details regarding this feature, please see: property.attachment.chunk.get

    3. Save the file into drive

  5. Create roles or groups : You can also create your own role or group of roles. e.g.

Roles / Groups are created only by running the pipeline with system user only.

Note: To get more details regarding this feature, please see: property.attachment.chunk.get

  1. Give permissions for accessing files to a role or a group.

  2. Evaluate any expressions.

4. Workflow Model

Workflow model enables you to map your data from entry-form to your application workflow. It allows us to use the inputted data throughout the application. The workflow model can be defined as follows:

Here, we define all the variables in key:value pair and store it in our workflow model.

Note: To get more details regarding this feature please see: Workflow Model

5. Save Workflow Model Into Schema

It enables you to save the entry-form data into a schema. Schema is a file where we define all the fields that are there in entry-form with their data types. The file is in JSON format. e.g.

Note: To get more details regarding this feature, please see: property.schema.put

6. Start Workflow

In this section, we define those variables which we process and use them in the subsequent steps. We use workflow.start to start processing the fields from the entry-form and map them in key:value pair and then use later in different pipelines e.g.

Note: To get more details regarding this feature, please see: workflow.start

You can access these process variables in the next pipeline as following:

vars.fname, vars.email, vars.account, vars.comment

BPMN Gateway

A gateway in BPMN is a branch of the workflow. Depending on a condition, the flow of the process can branch into different directions.

Where to define gateways conditions?

In this example, depending on whether the supervisor has approved or declined the vacation request, the workflow should execute the “Send declined email” or the “Send approved email” task. For this, we need to define rules on the gateway edges:

  1. To define the rule for the decline gateway, select the declined edge of the gateway and fill-in this condition: ${vacationApproved == false}:

  2. This makes sure that this branch is executed in case the supervisor set vacationApproved to false in the task form.

  3. Repeat these steps for the task “Send approved email”, and set the condition to
    ${vacationApproved == true}.

  4. Click SAVE to save the current state of the BPMN workflow.

How to design gateways

The gateway design is defined by a specific expression language named JUEL. Below, you will find that the most important operators are:

  • Arithmetic+- (binary), */ and div% and mod- (unary)

  • Logicaland&&or||not!

  • Relational==eq!=ne<lt>gt<=ge>=le. Comparisons can be made against other values, or against boolean, string, integer, or floating point literals.

  • Empty: The empty operator is a prefix operation, that can be used to determine whether a value is null or empty.

  • ConditionalA ? B : C. Evaluate B or C, depending on the result of the evaluation of A.

For more details see https://docs.oracle.com/javaee/5/tutorial/doc/bnahq.html

Examples of gateway conditions

Condition for dropdown

  • Condition refers to a field named “decision”

  • Field provides a dropdown list for the user (Approve, Decline, or Delegate)

  • Gateway should represent the “Approve” selection

  • Condition looks like this:

Condition for checkbox

  • Condition refers to a field named “checked”

  • Field provides a checkbox

  • Gateway should represent the situation that the checkbox is ticked

  • Condition looks like this:

${ checked } works as well. Similarly, ${ !checked } can be used in place of ${ checked == false }

Condition for value

  • Condition refers to a field named “Kosten”

  • Field provides the option to type in numbers

  • Gateway should represent the situation that the value is > 100, but < 1000

  • Condition looks like this:

Multiple conditions

  • Condition refers to the fields: “decision” and “checked”

  • Field “decision” provides a dropdown list for the user (Approve, Decline, or Delegate)

  • Field “checked” provides a checkbox

  • Gateway should represent the situation that:

    • “Approved” is selected from dropdown

    • Tick is set for “checked”

  • Condition looks like this:

Workflow Variables

All values entered in a form are stored in variables and can be displayed & edited with subsequent task forms. In this section, you will learn how to display those variables.

Define form fields as workflow variables

In case, you are defining form fields via the Online Workflow Modeler, like in the example below, all field IDs are directly stored as workflow variables. If you use those IDs in multiple steps in the workflow model, the content entered in previous steps are displayed automatically.

In case, you would like to use workflow variables from a trigger form, there are a few additional steps to do. These steps are described in this tutorial Tutorial: Create a new BPMN workflow, section 9 & 10.

Display workflow variables

To display values entered during the workflow in subsequent (task) forms, you can just create a field with an identical ID in the Online Workflow Modeler (e.g. taxRate).

Make a variable read-only

As default, the values are editable. That means a user, who is assigned to this task, is able to see the entered value and overwrite it. To change it to “read-only”, you have to follow these steps:

  1. Go to your BPMN model (for example, in the online editor)

  2. Open the XML view of your model

  3. Add this section below the field you would like to define as “read-only” and save it:

Example:

In this example, the field named f1 is set to read only.