Tutorial 14: Create a BPMN Workflow
- 1 Introduction
- 1.1 Prerequisites
- 2 Step 1: Create a new BPMN workflow
- 3 Step 2: Add form fields
- 4 Step 3: Add Gateway Conditions
- 5 Step 4: Create and link the automation pipeline
- 5.1 Repeat to learn
- 6 Step 5: Deploy and start the workflow
- 7 Step 6: List deployments and instances (optional)
- 8 Step 7: Start workflow and assign a task to a user
- 9 Step 8: Claim and complete a task
- 10 Step 8: Use workflow variables in side automation pipeline
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:
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.
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.
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:
Declined: Send declined email to the requester.
Approved: Send approved email to the requester.
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:
What is a pipeline and a command and how to execute it in PIPEFORCE.
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.
Login to the portal at https://<your-namespace>.pipeforce.net (replace <your-namespace> with the namespace of your PIPEFORCE instance).
Go to LOW CODE → Properties and create a new app with name io.pipeforce.tutorial-14-bpmn.
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.
Use the name vacation-request as Workflow Name and click CREATE.
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:
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:
Repeat these steps with the next task “Review request” to have two user tasks like this:
Now, let's add the gateway and a service task:
Repeat these steps to create the second service task, and to add an end task. Finally, your BPMN diagram should look like this:
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:
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.
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:
In the Workflow Designer, select the
Request vacation
task, and go to theFORM
tab on the right.Make sure the Form Type is set to Simple.
Click the plus icon to add a new field.
Click the pencil icon on the field to open the field details.
Set the values for the vacationStartDate like this, and click
APPLY
:Repeat this step for the field “Vacation End”:
ID =
vacationEndDate
Label =
Vacation End
Type =
date
Click
SAVE
to save the current state of the BPMN workflow.
Create the form fields for the Review request service tasks:
Now select the Review request task and add these field values:
ID =
vacationApproved
Label =
Vacation Approved
Type =
boolean
Click
SAVE
to save the current state of the BPMN workflow.
Now sit back and think about these questions and try to answer yourself:
What would happen if we would execute this workflow in this state?
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:
Select the declined edge of the gateway, and fill-in this condition:
${vacationApproved == false}
:This makes sure that this branch is executed in case the supervisor has set
vacationApproved
to false.Repeat these steps for the task “Send approved email”, and set the condition to
${vacationApproved == true}
.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:
What would happen if we would execute this workflow in this state?
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:
Open your BPMN workflow in the editor and click the service task Send declined email.
The details pane opens at the right side. Select the tab PIPELINE.
Click the plus icon right of the dropdown field in order to create a new pipeline.
A new editor window opens. Use the name send-declined-email and click CREATE.
The pipeline will be created and the pipeline editor opens in a new tab.
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:
Go back to your service task Send declined email and make sure the pipeline send-declined-email is linked in the PIPELINE tab.
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:
What would happen if we would execute this workflow in this state?
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:
Before A BPMN workflow can be executed, it must be deployed.
A BPMN workflow in execution is called a process.
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:
In your workflow designer click the dots at the top right corner and select Start...
If asked whether you would like to deploy the workflow, click YES.
In the Start Workflow dialog click START.
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.
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:
Go to LOW CODE → Playground.
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.
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.
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:
Select the app io.pipeforce.tutorial-14-bpmn in the portal.
Click the plus + icon at the top.
Create a new Tile with name workflowstart.
Use this configuration (copy & paste + save the property):
Go to Installed App -> io.pipeforce.tutorial-14-bpmn
Click Start Workflow. The workflow was no started and assigned to the currently logged-in user which is you.
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:
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.
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.
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
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:
Open your pipeline send-declined-email
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.