Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 10 Next »

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.

Modelling a BPMN Workflow

In PIPEFORCE, workflows can be online designed using BPMN (Business Process Model and Notation), which is a worldwide ISO standard to describe business processes in a formalized (graphical) way. Therefore, also non-technical users can read and understand BPMN workflows. If you’re not familiar with BPMN so far, we highly recommend you to learn more about its basics 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 workflow, 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:

As you can see it is quite easy to understand what it going on in this workflow.

A BPMN workflow typically has a single start event, one or more user tasks or service tasks and a single end event. There are more elements possible, just to name a few for now.

Such BPMN workflows are typically designed using a BPMN designer tool. You can use your own local software to design such a diagram and then upload it to PIPEFORCE, or you can use the built-in online BPMN designer from PIPEFORCE, which supports:

  • Create BPMN workflows online in your web browser.

  • Discuss a BPMN diagram with your team.

  • Create or link service tasks with data pipelines.

  • Create or link user tasks with input forms.

  • Deploy and start the diagram so it becomes a workflow instance executing a real process.

  • Monitor running workflow instances.

In order to draw a BPMN diagram, the most important elements are these:

Lets shortly explain those basic items below.

Start Item

This is the starting point of a workflow and defines how the workflow will be started. This can be done manually or triggered by an event for example. If nothing is defined, it is always considered to be started manually.

User Task

The user task is the part of a workflow in case manual input from a user is required. For example to review some data and approve it. This input is typically requested using a form showing one or more form fields to the user he then can fill out.

Form

The workflow waits at this task until the user has filled-out the form and finished this task by clicking the “Complete” button of the form.

In PIPEFORCE such a form can be defined in the online modeller using the FORM tab.

image-20240808-094354.png

There are two form types available:

  • Simple = The form fields can be directly defined and will be displayed vertically one after another. This is the simplest approach but is limited. So for example you can not change the orientation of the fields, no special fields are supported, fields are limited to max. 4000 chars and validation is also quite limited.

  • Custom = These are advanced forms where you have full flexibility of the form framework to design your form. With this flexibility also complexity comes. See here for documentation about the form framework: Forms Framework.

Assignment

User tasks can be assigned in the workflow to specific users and user groups, by using the GENERAL tab. This can be done in the Assignment section.

Assignee is a single username. If defined, the user task will be automatically assigned to the user with this username when created.

The Candidate Users field define the users allowed to pick and claim this task. They will see the task instance of example in the TODO filter which can be seen as a “task pool”. Same is true if user is member in one of the groups mentioned in the Candidate Groups field. Multiple entries in these fields must be separated by comma.

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.

    pipeline:
      - event.listen:
          key: "property.created"
          filter: "#{body.payload.target.key.contains('global/app/travelexpense/object.travelexpense/v1/instance')}"
    

    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.

    pipeline:
      - event.listen:
          key: "property.created"
          filter: "#{body.payload.target.key.contains('global/app/travelexpense/object.travelexpense/v1/instance')}"
      - set.var:
          key: "formData"
          value: "#{@convert.toMap(body.payload.target.value)}"
    

    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.

    pipeline:
      - event.listen:
          key: "property.created"
          filter: "#{body.payload.target.key.contains('global/app/travelexpense/object.travelexpense/v1/instance')}"
      - set:
          value: "#{@user.firstName()?: ''}"
          output: "#{vars.creatorFirstName}"
      - set:
          value: "#{@user.lastName()?: ''}"
          output: "#{vars.creatorLastName}"     
    
  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

      vars:
        basePath: "global/app/appname/data"
      
      pipeline:
        - iam.run.as:
            username: "systemuser"
        - drive.mkdir:
            path: "#{vars.basePath}"
            recurse: "true"     
      

      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

      - set.var:
          key: "invoiceFileName"
          value: "#{vars.formData.formAttachment.filename}"
      

      Get content of file

      - property.attachment.content:
          key: "#{body.payload.target.key}"
          value: "#{vars.formData.formAttachment.content}"
      

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

    3. Save the file into drive

      - drive.save:
          path: "global/app/appname/data/#{vars.FileName}"
      
  5. Create roles or groups : You can also create your own role or group of roles. e.g.

    pipeline:
      - iam.run.as:
          username: "systemuser"
      - iam.role.create:
          name: "CAN_APP_APPNAME"
    

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.

    pipeline:
      - iam.run.as:
          username: "systemuser"
      - drive.share:
          to: "invoice-controller"
          type: "group"
          path: "global/app/accountspayable"
          permission: 1
    
  2. Evaluate any expressions.

      - eval:
          expr: "#{body.name = 'assignedvalue'}"
    

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:

- workflow.model:
    mappings: "
    uuid: vars.uuid,
    createrFirstName: vars.createrFirstName,
    createrLastName: vars.createrLastName,
    createrEmail: vars.createrEmail,
    createrUsername: vars.createrUsername,
    createrDate: vars.createrDate
    "
    output: "#{vars.workflowModel}"      

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.

- property.schema.put:
    key: "global/app/appname/object/workflowmodel/v1/instance/#{vars.uuid}"
    value: "#{vars.workflowModel}"
    type: "application/json"      

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.

- workflow.start:
    key: "appname_V1"
    businessKey: "#{vars.uuid}"
    workflowModelInstanceKey: "global/app/appname/object/workflowmodel/v1/instance/#{vars.uuid}"
    variables: "#{{
    'fname': (vars.formDatap['firstname']),
    'email': @user.email(),
    'account': (vars.formData['account']),
    'comment': (vars.formData['comment'])
    }}"
- body.delete:

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:

<camunda:validation>
  <camunda:constraint name="readonly" />
</camunda:validation>

Example:

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

  • No labels