Tuesday, July 7, 2015

From process descriptions to executable business processes

Many organizations have a considerable number of business processes documented in various formats such as plain text and flow charts. Some of these documented processes may have to be automated. A core part in automating a business process is to create an executable process from a documented process (e.g. plain text process). Let's see how we can do this using BPMN and how such executable processes can be enacted in WSO2 BPS.

We will take a procurement process for buying equipments for employees as an example. Below is the plain text description of the process:

An employee fills a procurements form and gets the approval from his manager. Then the employee hands over the form to the procurements department. Procurements department gets quotations from approved suppliers. Once quotations are obtained, it submits an appropriate form to the finance department for funds. If the funds are not approved, new quotations are taken and sent for approval. Once funds are approved, procurements department buys the item and hands it over to the employee. 

Our target is to create a BPMN model from the above process description. Tasks involved in the process, the flow of the process and people responsible for carrying out different tasks are described in the above text. We can identify the below tasks and roles responsible for those tasks:
  • Fill procurements form - Employee
  • Approve procurement - Manager
  • Get quotations - Procurements department staff
  • Approve funds - Finance department staff
  • Buy item - Procurements department staff
  • Handover item to employee - Procurements department staff
Each of the above tasks become a User Task in our BPMN model. We use the Eclipse based Activiti BPMN designer for modelling the process. To start with, create a new BPMN project from the menu File -> New -> Project. Select "Activiti Project" and give the project name as "XYZOrganization". Then right click on the created project, click New -> Other and select "Activiti Diagram". Give process model name as "procurementsProcess" and click "Finish". Now we have an empty BPMN model.

First drag and drop a start event from the pallet. Then drag and drop seven User Tasks to the canvas and rename them with above task names. Next step is to model the control flow, that is to model the connections among tasks. We can identify these connections easily from the process description. For example, "Fill procurements form" precedes "Approve procurement". To model such flows, simple connect the two tasks with a sequence flow. The only part in the control flow that needs bit more attention is the outgoing flow from the "Approve funds" task. There are two possible outcomes of this task: Funds can be approved or rejected. According to the process description if the funds are not approved, new quotations have to be taken and sent for approval. If funds are approved process can proceed to the "Buy item" task. Therefore, we have introduce a decision point here, which is modeled using an exclusive gateway in BPMN. Drag and drop an exclusive gateway to the canvas and connect it to the "Approve funds" task using a sequence flow. This exclusive gateway models a decision point. Accordingly it has to have two outgoing flows to model different paths taken by the decision. One outgoing flow simply connects to the "Buy item" task. The other outgoing flow should be connected to the "Get quotations" task. However the flow from "Approve procurement" task also connect to the "Get quotations" tasks. Therefore, this is a converging point in the process as two flows join to form a single flow. Only one converging flow can be taken at a given time, which means they are exclusive converging flows. Such converging points can also be modeled using exclusive gateways in BPMN. Just drag and drop an exclusive gateway and connect the flows as shown in the below diagram. Finally, we mark the completion point of the process by adding an end event and connecting the "Handover item to employee" task to the end event. Now we have captured the control flow of the process as shown in the below figure. Although the figure contains pools and lanes, we can ignore them as the current version supports them only for display purpose.



The next step is to enrich this model with details required for process execution. First, we have to specify the role that is responsible for performing each task. In the BPMN designer, click on the "Fill procurement form" task to view the properties of this task. Click on the "Main config" tab in properties and enter "employee" in the "Candidate groups" field as shown in the below figure:



Similarly, assign appropriate tasks to "manager", "procurementsStaff" and "financeStaff" roles. Now we are done with the control flow and resource assignment steps of our process model. Next step is the data modelling, which is to specify which data elements are required for each task and how those data elements are used by other tasks. Let's assume that the employee has to specify what equipment is required and the purpose of the equipment in the procurements form. Therefore, "Fill procurement form" task has three output data elements called, for example "emplyeeId", "equipment" and "purpose". Then the manager needs to know the equipment applied for and its purpose for approving the request. Further, he will specify whether the application is approved or not. Thus, "Approve procurement" task has two input data elements: "equipment" and "purpose". The output data element of this task is "approvalStatus". Similarly, we have to identify input and output data elements of each task and specify them in our BPMN model.

Click on the "Fill procurement form" task and select "Form" tab in the properties window. Click "New" button to bring up the new form property window. Specify the property ID as "equipment", name as "Equipment" and type as "string" as shown in the below figure. Property ID is used to refer to the property within the process model. Property name is the human readable
name of the property, which is displayed in forms presented to end users.

Similarly, add the "purpose" and "employeeId" form properties to the "Fill procurement form" task. Once properties are added, form tab of the properties window will look like below:


Next is to fill up data elements for the "Approve procurement" task. Here we have to give "equipment" and "purpose" as inputs and get "approvalStatus" as the output. Go to the form properties view of the "Approve procurement" task and add two properties with IDs "equipment" and "purpose". As we are giving the same IDs that we gave in the "Fill procurement form" task, we are referring to the properties used in that task. As we do not want users to modify those two properties we can set the "Writable" property to false. Then add another property with ID: "approvalStatus", name: "Approve the request" and type: "string". In the same way, we can fill up the data elements for other tasks.

One task that needs particular attention is the "Approve funds" task as the output of this task is used in deciding the subsequent process flow (i.e. in the exclusive gateway). Therefore, let's add a property with ID: "approveFunds", name: "Approve funds" and type: "string". Now if the "approveFunds" property is set to "no", user should be redirected to "Get quotations" task. If it is set to "yes", process will continue to "Buy item" task. Select the sequence flow connecting two exclusive gateways and go to the "Main config" tab in the properties window. Enter ${approveFunds=='no'} in the "Condition" field. Then select the sequence flow connecting the exclusive gateway and "Buy item" task and in the "General" tab of the properties window, enter "approvedFlow" in the "Id" field. Then select the exclusive gateway next to "Approve funds" task. In the "General" tab select "approvedFlow" under the "Default flow" field.

We are done with modelling the process. Now we have to export the process as an archive so that it can be deployed in WSO2 BPS. Right click on the project and select "Export" from the menu. In the export dialog, select "Archive File" under the "General" section and click "Next". Select "procurementsProcess.bpmn" file from the "XYZOrganization" project. Fill in the export destination and make sure to name the archive with extension "bar" (e.g. xyzprocurements.bar). Filled export dialog is shown below:



Now we have our procurements process ready to be executed. Let's try it out.. Start WSO2 BPS and go to the management console (https://localhost:9443/carbon/). Under "Processes" -> "Add" click "BPMN". Browse the exported BPMN archive (i.e. xyzprocurements.bar file) and click "Upload". Wait for few seconds until the process is deployed and click Processes -> List -> BPMN to view the uploaded BPMN process.

Business processes have many stakeholders and those stakeholders involve with processes in different ways. Business analysts work with process editors to build models as we did with the Activiti BPMN designer. IT administrators deploy and manage processes as we just did with the BPS management console. Now it comes to real process participants working with process to perform their day-to-day business tasks. In our case, it is organizational staff working on a procurements procedure. WSO2 BPS offers a separate web application called BPMN Explorer for such process participants to work with the process. Let's view the BPMN Explorer by pointing the browser to https://localhost:9443/bpmn-explorer. Login to BPMN Explorer using username: admin and password: admin. Click the "Processes" tab to display the process model that we just deployed as below:



Click "Start" to start this process. However, we won't be able to do anything with the process other than starting it as none of the tasks in our procurements process are assigned to the admin role. Therefore, go to the BPS management console and create roles "employee", "manager", "procurementsStaff" and "financeStaff" and assign some users to those roles. Then first login to the BPMN Explorer from a user in the "employee" role. We can see that the "Fill procurement form" task is listed under the "Claimable tasks" tab. Click on the task name to brings up task details as shown below:



One thing to note here is the list of data items to be filled to complete the task. These are the properties that we specified when modelling the "Fill procurement form" task. However, we cannot fill anything until we claim the task. Click "Claim Task" to claim the task, so that the task will be assigned to the current user. Now the task will be listed under "My tasks" tab. Click on the task name to view task details as below:


Here we can fill the form with appropriate data and complete the task. Then the task lists of the current user becomes empty as no more tasks are assigned to users in "employee" role. Then login again using a user in the "manager" role and go to the "Claimable tasks" tab. We can see that the "Approve procurement" task is listed there. Claim it and open the task from "My tasks" tab. As shown in the below figure, we can notice that the equipment and purpose fields are already filled with the values we have entered before.



Fill in the approval field and complete the task. Then log in using "procurementsStaff" and "financeStaff" users to complete subsequent tasks accordingly.

We just saw the execution of our procurements process in WSO2 BPS. Basically, what BPS does is to follow the process flow of the BPMN model and assign tasks to users in relevant roles. Once a task is completed, BPS follows the process flow to the next task and assign it to appropriate users. From the users point of view, what they get is a list of tasks for them to work with. They can claim any task from the list, fill necessary details and complete it. Once a task is completed, new tasks will be added to the same user or to some other users depending on the process model. This is how an automated business process coordinates users to perform tasks required for a business goal.


Friday, July 3, 2015

Towards business friendly process modelling with BPMN

WSO2 Business Process Server (BPS) will support BPMN starting from the upcoming release. You can try out the beta release from here.

So what's in it for WSO2 BPS users? How would an organization benefit from BPMN based business processes? Let's start by looking at the purpose of business processes and business process modelling.

Business process is a collection of interrelated tasks used to achieve a business goal. Let's take an example of buying a new laptop for an employee. First, the employee has to fill a procurement form and get the approval from his manager. Then the employee hands over the form to the procurements department. Procurements department gets quotations from approved suppliers. Once quotations are obtained, it submits appropriate form to the finance department for funds. If the funds are not approved, new quotations are taken and sent for approval. Once funds are approved, procurements department buys the laptop and hands it over to the employee. Here we see a (simplified) business process for procurements. As mentioned above, this process has tasks such as "Fill procurements form", "Get manager approval", "Get quotations", etc. The process also has interrelations among tasks such as "Fill procurements form" precedes "Get manager approval", "Get quotations" precedes "Get funds", etc.

A typical organization can have a large number of business processes for achieving various business goals such as handling sales orders, processing employee leave applications, recruiting new employees, launching new products, etc. To complicate this further, each of these processes may have multiple subprocesses. For example, the process of recruiting new employees may contain subprocesses for scheduling interviews, preparing employment offers and provisioning IT services for new employees.

So what is the purpose of modelling these processes? Although we like it or not, there are many processes in any organization. Further, these processes exists to fulfill business goals at various levels. Therefore, if we want to know how we are going to achieve our business goals we have to know on our processes. This is why we need business process modelling. By modelling business processes using a suitable notation, we can easily understand details of a process such as what are involved tasks, how certain tasks depend on other tasks and who are responsible for performing different tasks. In addition, if we use a standard notation for modelling, those process models can be used to communicate with process stakeholders. For example, once business analysts prepare a process model, they can hand over the model to the division head for approval. Then the same model can be used by process participants to understand tasks to be performed at different stages of the process. Wait.. what if the same model can be executed in a Business Process Server (BPS)? This is where BPMN comes in..

BPMN provides a rich notation for modelling business processes while trying to be simple enough to be understood by business users. At the same time, BPMN is an executable language, which means it can be executed in process servers in order to automate business processes. As an illustration, below is a BPMN model of the laptop procurement process we discussed above:




A business analyst working with process stakeholders can drag and drop BPMN elements and connect them as necessary to draw up such BPMN model. This model can be used understand and analyze the process. For example, it is clear that the current model has no action to take if the management approval cannot be obtained or if no quotations could be obtained for the given laptop. Once we visualize the process using BPMN, such points become more visible and allows us to introduce to possible improvements. If the staff of the organization has some minimal BPMN knowledge, this model can be used to communicate the process. For example, an employee working in the procurements departments understands that quotations have to be obtained before submitting for funds approval. Such benefits of clearly understanding and communicating business processes become more prominent when processes contain large number of tasks with complex interrelations and hierarchies of subprocesses.

Then comes the best part... If we add little more details to this process, it can be executed directly on a process server such as WSO2 BPS. That is, we can get the procurement process automated. Once automated, an employee who needs to get a new laptop just have to trigger the procurement process. Then BPS will assign relevant tasks to appropriate users and coordinate the flow of tasks according to the BPMN model. In this way, users just have to work on tasks assigned to them while BPS performs all coordinations among users, other processes and external systems.

As we have discussed, BPMN is a great tool for capturing real business processes and automating them. Therefore, the support for BPMN in WSO2 BPS allows BPS users to move towards business friendly process automation.