One of the new features that Mendix has released with the arrival of Mendix 9 is workflow management. This functionality opens up new possibilities for easily modeling all forms of processes where a series of actions are performed. Examples of this are approval processes, or other processes in which decisions are made by different actors. This enabled us to see opportunities with our customers for process optimization compared to the current implementation in which we used microflows.
In the previous article we already described the application of Mendix workflow to organizing a Christmas dinner. Then the focus was on what the application of Mendix Workflow is, without going into the technical aspect. In this article we explain in detail how using a workflow works in Mendix Studio Pro. We describe the steps you need to take in Mendix to build a workflow, give tips that can help you set up a workflow yourself and illustrate this with screenshots. Here we take a closer look at the example of Chelsea's Christmas dinner that we described earlier.
When it comes to workflows, the first step is to describe and outline the desired process. A suitable method to get started with this is to create a swim lane. This makes it clear at a glance which actors are involved in the process and who has to make a decision at what time. This process plate can be used as input for the workflow.
As soon as the process has been drawn up, the module roles to be used will become visible. Each swim lane equals a separate role within the application. Make sure that all these user roles are created in the model, so that each user only sees the pages and processes that he or she needs to perform. In our example of the Christmas dinner, one could think of the user roles 'guest' and 'host'.
After the user roles have been determined and created, it is time to add the workflow to the Mendix model. This can be achieved by right clicking on the module and selecting “Add workflow”. A workflow will then appear and it must be linked to a workflow entity.
A workflow entity can be added in the domain model as a specialization of Sytem.Workflow. This entity can be given a generic name such as 'MyFirstModule.Workflow'. A separate workflow entity will have to be created for each workflow. The entity can then be linked in the workflow by right-clicking and selecting “select workflow instance”.
Don't forget to set up the entity access of this entity so that all participants in your workflow can view its data.
In addition to a generic workflow entity, an entity is also needed for the business context. In the example described, the business context entity could be 'MyFirstModule.Christmas Dinner'. The workflow itself describes the status of the work process and differs in this respect from the business context entity, the latter containing the information that follows the process. An example of business context information is, for example, the actual dietary requirements of the guests, whereby the workflow itself determines whether the dietary requirements have been submitted.
The last type of entity required for a workflow is the user task entity. Like the previous entities, these too are set up as a specialization of the system.Usertask entity. It is mandatory to create one user task entity per task to be performed by a user. From Mendix 9.7 this is done automatically for you. Some entities that we can deduce from the Christmas dinner example are: 'sending invitations', 'shopping', etc.
The next step to take is to create pages. A separate page can be created for each 'user task'. This page has the page parameter 'myfirstmodule.Christmas dinner' and then shows the information related to the step. For example, at the step sending invitations you want to see the guest list and the available dates. At the shopping step you want to see all the ingredients of the chosen dish plus the dietary requirements of the guests.
By using a 'Page Template' in Mendix you can ensure a consistent display throughout the process. Mendix has two sample page templates in the WorkflowCommons module for displaying an entity with workflow information.
Each step in the workflow is performed by a specific user group. The first step for this is to assign a user role to the task. For example, a microflow can be used. In this microflow, the correct user role can be retrieved by means of a retrieve from the database and given to the settings in the workflow task. In the Christmas dinner example, the system role “Host” would be retrieved from the database, to be assigned to the workflow step “Send invitations”.
Do not forget to provide the UserTask entity with the correct entity access.
In the tab “Data” under the settings screen of the Workflow task you can then assign the entity that is used when generating the corresponding workflow page. The entity to be selected is one of the “UserTask” entities created in step 4.
A separate page must be generated for each step in the workflow. Pages cannot be reused in multiple workflow steps. Under the tab “Display information” the created page can be linked to the task.
When setting up the page, buttons can be created to activate the options within the task. In the Christmas dinner example, the “Respond to Invitation” page assigned to the “Guest” user role would have two buttons visible;
The steps described above should help you set up an initial workflow. This blog is based on the workflow functionalities available in Mendix 9.7.0. However, Mendix has indicated that changes can still be made in how the workflow is set up until 9.10.0.
To provide the best experiences, we and our partners use technologies such as cookies to store and/or access information about the device. Consent to these technologies allows us and our partners to process personal data such as browsing behavior or unique identifiers on this site and to display personalized and non-personalised advertisements. If you do not give consent or withdraw it, certain functions may be affected.
Click below to agree to the above or to make specific choices. Your choices will only be applied to this site. You can change your settings at any time, including withdrawing your consent, by using the buttons on the Cookie Policy or by clicking the 'Manage Consent' button at the bottom of the screen.