Tutorial 14: Create a BPMN Workflow

Introduction

In this tutorial you will learn how to design, deploy and start a BPMN 2.0 Workflow using No Code (= no coding is required).

In order to design and automate user workflows and discuss them with internal and external teams, it is inevitable to rely on official standards, that everybody can easily understand and are accepted in industries worldwide.

This is the reason why PIPEFORCE uses BPMN 2.0 as such a standard to design and execute stateful workflows.

With this approach, it is easy to communicate and draw in a standardized format between development, departments and externals, since everybody can refer to the official BPMN standard for explaining, discussing and optimizing processes.

The workflow we are going to create in this tutorial will look like this:

 

 

It is a simple vacation request workflow:

  1. The first task is a user task which will provide a form to the employee he or she must fill out and submit in order to request vacation.

  2. The second task is also a user task which will provide a form. This form must be filled-out by the reviewer (typically a supervisor). She or he approves or declines the vacation request.

  3. In the third step, a gateway is used. Depending on the decision of the supervisor, the gateway will forward the process flow to one of these service tasks in the next step:

    1. Declined: Send declined email to the requester.

    2. Approved: Send approved email to the requester.

  4. Finally the process will stop in an end event.

Even if this workflow is a simple one, it contains already the most important items for a BPMN workflow:

  • A start event

  • User tasks “Request vacation” and “Review request”

  • A gateway to branch the workflow depending on the input

  • Service tasks to send emails

  • An end event

  • Connectors between items

With these elements, you can already create many different types of workflows and run them immediately in PIPEFORCE.

In the next steps of this tutorial, you will not only learn how to model such a workflow in BPMN but also how to bring this workflow to real life and use it in production.

For a detailed documentation about BPMN Workflows in PIPEFORCE see: Workflows (BPMN) .

Prerequisites

In order to execute this tutorial and to get the most out of it, you should have at least basic knowledge of these topics:

  1. What is a pipeline and a command and how to execute it in PIPEFORCE.

  2. What is the property store and how to save and load properties to / from it.

In case you do not fulfill these prerequisites, we recommend to first solve them.

Step 1: Create a new BPMN workflow

In this step you will model a BPMN workflow.

  1. Login to the portal at https://<your-namespace>.pipeforce.net (replace <your-namespace> with the namespace of your PIPEFORCE instance).

  2. Go to LOW CODE → Properties and create a new app with name io.pipeforce.tutorial-14-bpmn.

  3. Then, select your app, click the plus + icon and create a new workflow by clicking the BPMN Workflow tile or type-in work in the search bar and press enter.

  4. Use the name vacation-request as Workflow Name and click CREATE.

  5. The BPMN will be created and the designer is started.

Tip: In order to have more space in the designer, you can hide the very left menu by clicking on the top left grid icon. Clicking it again will bring back the menu:

 

The next step is to model the workflow using the online BPMN designer:

  1. Let's create the user task “Request vacation”. Add a new task, then click the wrench icon, and then select “User Task” from the list:

  1. Repeat these steps with the next task “Review request” to have two user tasks like this:

  1. Now, let's add the gateway and a service task:

  1. Repeat these steps to create the second service task, and to add an end task. Finally, your BPMN diagram should look like this:

  1. Click SAVE in order to save your workflow.

Tip: In case you have already created a BPMN file with a local BPMN modeller tool, you can also upload this file to your online BPMN editor. To do so, follow these steps:

Go to your local BPMN model.

Open the BPM in XML source view (usually any BPMN modeller tool allows to switch to a XML view).

Copy the XML.

Navigate to your online BPMN workflow or create a new one and open it in the online editor.

Click tab "CODE".

Paste the XML and click SAVE.

 

In this step of the tutorial you have learned how to create and model a BPMN workflow. This is great in order to start discussions with your team and stakeholder.

In the next steps you will learn, how to add forms to your workflow so the requester can start the workflow and the reviewer can review the request.

Step 2: Add form fields

In this step, we will enable forms and add input fields for them.

Noteworthy: There are two types of forms you can link to your workflow user tasks:

  1. Simple: A simple form which layouts all fields one under another. It is very fast and easy to create, thus it has limited flexibility in terms of layout and behaviour.

  2. Custom: A very flexible way to define forms. The layout and the behaviour of the form can be fully customized, thus it is more complex to implement.

In this step of the tutorial we will go with the Simple form type.

Create the form fields for the Request vacation service task:

  1. In the Workflow Designer, select the Request vacation task, and go to the FORM tab on the right.

  2. Make sure the Form Type is set to Simple.

  3. Click the plus icon to add a new field.

  4. Click the pencil icon on the field to open the field details.

  5. Set the values for the vacationStartDate like this, and click APPLY:

  6. Repeat this step for the field “Vacation End”:

  7. ID = vacationEndDate

  8. Label = Vacation End

  9. Type = date

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

Create the form fields for the Review request service tasks:

  1. Now select the Review request task and add these field values:

  2. ID = vacationApproved

  3. Label = Vacation Approved

  4. Type = boolean

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

Now sit back and think about these questions and try to answer yourself:

  1. What would happen if we would execute this workflow in this state?

  2. What is missing so the workflow will fully work?

In the next step we will add the gateway conditions in order to decide whether to send a declined or approved email depending on the input in the Review request form.

Step 3: Add Gateway Conditions

In this step we will add the gateway conditions in order to decide whether to send a declined or approved email.

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. 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 has set vacationApproved to false.

  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.

Note: The workflow engine of PIPEFORCE uses the Unified Expression Language (EL) which is similar to the Pipeline Expression Language (PEL) but differs in some aspects. You can find more information and examples here.

Now sit back again and think about these questions and try to answer yourself:

  1. What would happen if we would execute this workflow in this state?

  2. What is missing so the workflow will fully work?

At this stage, the BPMN is only a design without any real behaviour. In the next steps of this tutorial, we are going to change this and bring the BPMN to live.

Step 4: Create and link the automation pipeline

In this step we will link each service task with a pipeline in order to execute real actions.

Up to this step, the BPMN is just a design / concept without any real behaviour. In this step, we will change that.

As you can see in the workflow, there are two service tasks, both of which will send an email.

A service task is a task, which is typically not executed by a human but automated by a service.

In PIPEFORCE, this is done by mapping such a service task to a persisted pipeline. The pipeline acts as the glue to link the task to automation and integration steps.

A pipeline in PIPEFORCE is a sequential flow of steps which can execute a list of real commands like connecting to external systems, doing data validation, sending an email and many more things. See here for more details about pipelines and commands.

Whenever the service task is executed later, it delegates to the linked pipeline, executes it in a sync way and then returns with the result into the workflow process.

The step of linking the BPMN workflow with a pipeline is also called weaving, since the pipeline will be "weaved" into the BPMN workflow. This important step will bring the workflow finally to live. Weaving in PIPEFORCE is also known as the phase in workflow implementation, where developers can now step in and help adding integrations, data mappings or other development tasks if required. It is a clear interface between business and development.

So lets do the weaving and link your service tasks with pipelines:

  1. Open your BPMN workflow in the editor and click the service task Send declined email.

  1. The details pane opens at the right side. Select the tab PIPELINE.

  1. Click the plus icon right of the dropdown field in order to create a new pipeline.

  1. A new editor window opens. Use the name send-declined-email and click CREATE.

  1. The pipeline will be created and the pipeline editor opens in a new tab.

  1. Now lets add a command to this pipeline which will send a simple email to you. To do so, copy and paste this YAML script to send-declined-email and save it:

pipeline: - mail.send: to: "requester@email.tld" subject: "Vacation Request Declined" message: "Hello, your vacation request was declined. I'm sorry."

Note: In order to be able to test this, you should replace requester@email.tld by your own email address.

Hint: As an alternative, you can also use the pipeline designer in order drag & drop this pipeline without any coding at all. Search the mail.send command in the right menu and then drag & drop it to the left.

Finally you need to set the to, subject and message parameters:

  1. Go back to your service task Send declined email and make sure the pipeline send-declined-email is linked in the PIPELINE tab.

  1. Click SAVE in order to save this change.

10. Done. You have now linked your service task with a pipeline. Any time the service task Send declined email is executed, it will delegate execution to the pipeline send-declined-email which will send an email.

Repeat to learn

Now repeat the last steps from above by your own and create another pipeline this time with name send-approved-email and link it with the service task Send approved email. You can use this pipeline script:

pipeline: - mail.send: to: "requester@email.tld" subject: "Vacation Request Approved" message: "Hello, your vacation request was approved :-) "

Note: In order to be able to test this, you should replace requester@email.tld by your own email address.

Finally, you should have two service tasks, each linked to another pipeline. In case the vacation request was approved, the approved email will be send. Otherwise, the declined email will be send.

Now sit back and think about these questions and try to answer yourself:

  1. What would happen if we would execute this workflow in this state?

  2. What is missing so the workflow will fully work?

In the next step you will learn, how to add deploy and start to your workflow.

Step 5: Deploy and start the workflow

In this step we will deploy and start the workflow using the web portal.

Noteworthy:

  1. Before A BPMN workflow can be executed, it must be deployed.

  2. A BPMN workflow in execution is called a process.

  3. The step to assign a user task to a specific user or group is also known as "to claim" a task.

So let’s do this:

  1. In your workflow designer click the dots at the top right corner and select Start...

  1. If asked whether you would like to deploy the workflow, click YES.

  1. In the Start Workflow dialog click START.

  1. Make sure the workflow was successfully deployed and started by clicking the INSTANCES tab. Here you should see a single instance id which is the id of your started workflow.

  1. Now you have started a workflow, but it is not assigned to any user. Therefore you cannot see it in the My Tasks list.

This we will solve in the next step of this course.

Optional: Deploy and start workflow via automation pipeline

Optional steps for advanced / interested users: Deploy and start your workflow using a pipeline.

Note: This tutorial step is optional and only suggested for advanced users.

Another option to deploy and start your workflow is by using a command. This is useful in case you would like to fully automate even the workflow deploy and start process. In this step, you will learn how to do this.

Steps to deploy and start your workflow using a pipeline:

  1. Go to LOW CODE → Playground.

  2. Execute this pipeline:

pipeline: - workflow.deploy: propertyPath: global/app/io.pipeforce.tutorial-14-bpmn/workflow/vacation-request - workflow.start: key: ${body.name}

This pipeline will execute two commands in one call: It will deploy and then start the workflow by referring to its name as a process and finally will return you the process id, like this example shows:

Step 6: List deployments and instances (optional)

Optional steps for advanced / interested users: List all deployments and process instances using a pipeline.

In case you are not familiar with pipelines or don't want to write low code, you can skip this step and go on with next.

  1. You can list the deployed workflow using a pipeline. Go to LOW CODE -> Playground and execute this pipeline (or use the pipeline designer):

This lists all deployments including the one deployed by you. You should see an entry like this in the output (there can be more than one deployments on your instance):

As you can see, the name of your deployment is io.pipeforce.tutorial-14-bpmn_vacation-request since a combination like this is automatically created on deployment: <APP_NAME>_<WORKFLOW_NAME>.

Remember this whenever you would like to refer to your deployment and execute it for example. It is also known as the workflow key.

  1. You can list all instances using the workflow.find.processinstances command with your workflow key from above as argument. Go to LOW CODE -> Playground and execute this pipeline (or use the pipeline designer):

This will return you all process instances of the given workflow as JSON.

Step 7: Start workflow and assign a task to a user

In this step you will start a workflow and assign the first task to the logged-in user using a custom tile:

  1. Select the app io.pipeforce.tutorial-14-bpmn in the portal.

  1. Click the plus + icon at the top.

  1. Create a new Tile with name workflowstart.

  1. Use this configuration (copy & paste + save the property):

  1. Go to Installed App -> io.pipeforce.tutorial-14-bpmn

  1. Click Start Workflow. The workflow was no started and assigned to the currently logged-in user which is you.

  1. Go to WORKFLOW -> Tasks → Assigned to Me. You should see the task listed here. Select it. Set Vacation Start and Vacation End date, then click COMPLETE.

After you have completed the vacation request, the task disappears from your list since now the process flow is already in the next step: The Review request step:

Step 8: Claim and complete a task

In this step you will learn how you can manually claim and complete a task in the portal.

Noteworthy:

  1. Claiming a task means assigning it to a specific user for completion and is usually done automatically. In this tutorial we will do it manually in order to show you how this works.

 

  1. Go to WORKFLOW → Tasks Assigned to Me.

As you can see, there are no tasks listed for you. The list is empty. The reason is because no task is assigned (= claimed) to you so far (at least related to this tutorial).

This we gonna change in the next step.

  1. Select the filter All Tasks.

Now you should see the task Review Request in the list. Click it.

Now click on top right corner: Claim

  1. After you did claim the task Review Request, it will again become visible in your Assigned to Me filter.

Select Vacation Approved and click COMPLETE.

After a while, you should get the approval email to your inbox.

Congratulations, your approval workflow is alive and works!

In the next steps we're going to improve this workflow a bit.

Step 8: Use workflow variables in side automation pipeline

In this step you will learn how to use workflow variables in a pipeline.

Currently, your pipelines send-approved-email and send-declined-email are static. There is no dynamic behaviour or data in them.

Now, we are going to change this and use the vacationStartDate and vacationEndDate variables from the user forms and refer these values from inside the pipeline to send them with the email message.

All workflow variables like form fields are automatically passed to a pipeline to the vars scope. Inside the pipeline, you can then access these variables. Examples:${vars.vacationStartDate}, ${vars.vacationEndDate}:

Change your pipelines in order to use the workflow variables:

  1. Open your pipeline send-declined-email

  1. Change the email message like shown below:

As you can see, we use the @date.format util to format the date and place the result in the email message.

Click SAVE to save the pipeline.

Repeat the steps with the pipeline send-approved-email.

Now, execute the workflow again and you should receive emails with the vacationStartDate and vacationEndDate dynamically set, like this example shows:

This way you can access any workflow variable inside your pipelines.