
Mendix Workflow — An Overview
In general, business process management or BPM is an important Enterprise Application which can help an organisation to reduce manual work done on paper, converting all those words, excel docs and pdf approval forms into a digital format. It enable’s users to maintain, track and easily deliver high-quality output. Today, I will demonstrate how easily Mendix, the Low-code platform, has the ability to make a BPM process.
Download the source code here
Let’s get started with my example of an employee on boarding process in Mendix version 9.6.
First of all, I would like to thank the Mendix Academy for their learning path on Workflow. I’m writing this blog in order to explain some more details and to provide insight into the new update of the workflow engine in Studio Pro version 9.6.0. So let’s get started.
Please download Mendix Studio Pro 9.6.0, if you experience any issues you check this guide to troubleshoot the installation.
Step 1— Create the Project
When you open studio pro 9.6.0, you will see the welcome page with your projects or apps like this picture below.

Select “Create New App” button near stop left of application screen. Then select “Blank Web App”.

Press “Use this starting point” button.

Name the application whatever name you want. I named it “StaffOnboard”.

Initializing the team server and free cloud environment can take several minutes the first time the project is opened. If you would like to save time you can set “Enable online services” to “No”, on the second red box in the picture above, it will jump you to the project quickly, because there will be no cloud creation activity, and the project will only be run locally. You should see a screen like the picture below.

Step 2— Add extra modules
The project needs the “Workflow Commons” module. To download follow these 3 steps easy steps :
1)Go to “Workflow Commons” in the Marketplace inside Studio Pro and click “Download”.

2)Confirm the import.

3) Confirm by clicking “Ok” to import

When everything is done, you can see that the module will place under marketplace modules.

Step 3— Change your security settings
Change your App Security Mode to be Production.

On the “User roles” tab, we need to add several roles for the workflow process. Follow the 4 steps below in order to add another 4 roles. Which are Facilities, HR, Manager, WorkflowAdministrator.

Configure the Facilities user role by following these 3 steps:
1)Under User roles click new.
2)Name the new roles “Facilities” and then click Edit on “Module Roles”.
3)Assign the new Role to be a “User” for all modules, except in your main module, where they should be assigned the module role “Facilities”.

Continue with HR role.

Continue with Manager role.

Last one is the WorkflowAdministrator role.

Back to “Module status” tab, the module “Datawidgets” has a notification for Entity access. Follow these 6 steps below to solve the notification.
1)Under “Module status” select the DataWidgets Module and double click “Entity Access”
2)Once inside Entity Access, click “New”
3)Select “User” under “Rule applies to the following module roles”
4)Set “Allow creating new objects” and “Allow deleting existing objects” to be true and set the default rights for new members to be “Read, Write”
5)Click “Set all to” be Read, Write
6)Click “OK”

When everything is complete. you should see something similar to the below.

Finally, press Ok.
Step 4— Change the module name and create entities
Now we can rename the module “MyFirstModule” to “StaffOnBoard”.


In the “StaffOnBoard” module, we need to create several new entities in the Domain model.
Start with main table which will be named as “StaffOnBoard”

ENU_LaptopModel

ENU_PhoneModel

StaffOnBoard Entity access setting

We need to make another entity called $WorkflowInstance which will be generalized with the System entity $Workflow. $Workflow is a core Mendix entity, which when used to create objects which inherit properties from it, have everything they need to create a workflow. This is all done in 2 steps, which I will show now below. Make sure that you make the association 1–1 with your StaffOnBoard entity.
1)In the properties of the entity, click Select onGeneralization.
2)Select Workflow and click OK

All user roles who will interact with the workflow entity will need read and write access to the WorkflowInstance Entity.

Now, the Facilities Item need to be defined. In several cases, it should be linked with Purchase Order process. Once the headcount is established, these purchase orders should trigger or become available since before a new headcount approval process can begin. You may take this idea and continue to build on it in your own way. For this scenario, I will auto add the Facilities Item, whenever HR staff user triggers a new on boarding process.
Facilities Entity.

ENU_ItemType

Facilities entity access setting.

Facility Items page overview

Almost done with all the entities. We still need another 4 entities to align with user tasks in the workflow.
Entity needs to specify which device a new Staff member can get.

Entity Access for ManagerSpecifyDevice task


We also need to specify where a member of staff will have to work.

Entity Access Setting

And we will have to allocate and prepare a desk for the staff member.

Entity Access Setting

We can also add an entity for their mobile devices.

Entity Access Setting

This is what my domain model ended up as in the end.

Step 5 — Create Pages
To continue, we need to make a page for HR staff to be able to add new employees and start the on boarding process.

I created a page which looks like this, to do this you can follow the steps below

1)Add the building block “headerhero”, layout column is Auto-fill

2) Add button to “Create object” then configure it as shown below

The Edit page should be something like this

Roles to access the page should be HR.


3) Listview
To show the fullname of new staff, and allow HR to start on boarding process with “Start Onboarding” button.

To make a workflow, simply right click to module StaffOnBoard and select “Add Workflow”.

Step 6— Trigger the workflow
From the Start Onboarding button, it will trigger a microflow. This microflow will need to check the facilities on hand. If the facilities are empty, it will have to add one more to make sure a new Staff will successfully reserve the stuff they will need to use to do their job.
Let’s take a look of the whole microflow

1) Check if a Phone is available or not, if empty create a new one. If not empty add one more.

2) Do the same as in step 1, but check for laptops and desks.

3) Call workflow, check the status of the workflow and display the name. This is a very important point for developer to check workflow state. If it is “Inprocess” it means the workflow is started and has arrived at the first user activity.

Now we can take a look at the draft of the Workflow in the workflow editor


A Workflow needs to add 3 important items. First, workflowinstance which we have done in the beginning. Second, the workflowcontext which is the StaffOnBoard entity. Third, the admin page.





Step 7 — Create workflow
1)Create a Manager task to specify a device for a new staff member after HR starts the on boarding.

On the next tab, Display information. You can select to make a new page

Name the page specify device and select the layout type User task extended.



The “Data” tab is to keep the user task information and needs to be a generalization of System.WorkflowUserTask. Which we have done before.

when all configuration is done, the errors should all be gone.

2) Create Manager task to specify a location for new staff which will lead to facility management.

You can make a new page like we did for Specify Device


Again on the “Data” tab, we will link with an entity which we have defined in an earlier step — ManagerSpecifyLocation

So far this is what we have now : 2 user tasks in the workflow

Now, after the Manager defined where the Staff should work. The workflow will split or flow in 2 different directions. If the user works at home, then the device will ship and we will have the deduction of facility items. On the other hand, if the staff member needs to be in the office, the desk should be prepared.
3) If the staff member decides to work from home.
after selecting the attribute, the outcomes of the split will contain true or false.

4) Ship the device if they work from home.
The configuration should be similar to specify device and specify location. However, the owner of this activity is Facility Staff, no longer the manager anymore.


Do not allow the Facility Staff to adjust the information, by disabling edit-ablity on the dataview.

Data is mapped to an entity generalized from the System.WorkflowUserTask.

5) Prepare Desk if they will work in the office.


Again, we will not allow to edit the form data.


The workflow so far.

6) Ship Device Logic.
When we ship the device, the facility items should be deducted. Workflow allows us to make a microflow call after a UserTask activity.



7) Prepare Desk Logic.



Step 8 — Final Project Settings (Demo user’s, Page access and Navigation).
To test the project, we need to set up some demo users.

Page Access for all user roles

Go to Navigation and add the homepages for each role as shown in the image below. We can use pages from the workflow commons module, and the pages we made previously.

Change default home page to the StaffOnBoard page.

Update the menu to resemble the picture below

Once you are done you can run your app and test it out, here’s a recording of me testing the app below
Demo Video
Source
Read More
From the Publisher -
If you enjoyed this article you can find more like it at our Medium page. For great videos and live sessions, you can go to MxLive or our community Youtube page.
For the makers looking to get started, you can sign up for a free account, and get instant access to learning with our Academy.
Interested in getting more involved with our community? You can join us in our Slack community channel or for those who want to be more involved, look into joining one of our Meet ups.