Creation of Transactional Sub-Processes

<< Click to Display Table of Contents >>

Navigation:  Bizagi Studio > Process wizard > Model Process > Modeling for execution > Sub-Processes > Understanding Transactional Sub-Processes >

Creation of Transactional Sub-Processes

To illustrate how to configure Transactional Sub-Processes we will use the following diagram:

 

Configurind Transactional8

 

The diagram refers to a Travel Request Process.

 

A Travel Request Process includes the necessary Activities to receive and handle travel requests made by the employees of a company. We will transform the Bookings Task to a Transactional Sub-Process taking into account situations that need special treatment.

 

In order to configure a Transactional Sub-Process follow the next steps:

 

1. Go to step 1 (Model Process) of the Process Wizard and click Edit Process.

 

Edit a process1

 

2. Right-click the task you wish to convert to transactional Sub-Process, in this case the Bookings task, and select the option Transform to Sub-Process

 

Configurind Transactional9

 

 

3. The Sub-Process Wizard will launch.  A new window will display the Sub-process types. Select the Transactional option and click the Next button

 

 

Configurind Transactional1

 

 

4.  Enter a new name or select an existing Process model from the drop-down list, and click Finish.

 

 

Configurind Transactional10

 

 

5. Once the sub-process is created, you can immediately edit it.

Right-click the newly created sub-process (Bookings) and select the option Edit Sub-Process.

 

 

Configurind Transactional11

 

 

6. The window will display the Sub-Process diagram.

When you create a process for the first time, a blank diagram appears with a pool containing one lane an one phase. You can model the process based on this diagram.

 

In the Bookings Sub-Process the Administrative Department manages the car, hotel and flight bookings simultaneously as requested by the employee. When the bookings are done, the Sub-Process terminates. The Process flow is depicted in the following diagram.

 

Configurind Transactional12

 

In this scenario, many situations can arise during the Process development.

 

For instance, the Administrative Department may successfully confirm the car and hotel booking. However, when attempting to book the flight, no airline has seat availability on the requested date for the specific destination. As the car and hotel have already been booked for the given date,  these bookings need to be canceled and the employee notified.

This business scenario can be modeled as follow:

 

 

Configurind Transactional13

 

A Compensation Event is attached to the boundary of each booking Activity. This Event is used to activate a cancellation flow once it is triggered. In this case, the cancellation flow represents Activities that must be triggered manually by the user to resolve unexpected situations.

 

In the above scenario, the Compensation Events attached to the Car Booking and Hotel Booking Activities will be activated.  In turn, the Cancel Car and Cancel Hotel Compensation Activities will be enabled allowing the Administrative Department to handle the compensation for each of the effected Activities.

 

To associate a Compensation Event, right-click the Activity to be compensated,  and select the option Attach Event.  Choose the Compensate event.

 

Configurind Transactional14

 

The associated Compensation Task is automatically created. Do the same for the remaining two Activities.

 

Configurind Transactional15

 

To raise the cancellation we need to use an expression once the activity is finished (on exit)  and deviate the normal path towards the cancellation path (shown below). This function will add a cancellation log file in the project folder. The expression should be created on the fourth step of the Process wizard.

 

Configurind Transactional21

 

if(<TransactionProcess.HotelUnavailable>==true)

{

 CHelper.RaiseCancelIntermediateEvent("Cancel");

}

 

 

The expression needs the following function:

CHelper.RaiseCancelIntermediateEvent("String message")

 

Where String message is a tag to identify the cancellation in the log file.

 

7. Now we need to model the cancellation flow for the parent Process.

If the Activities are compensated, the corresponding case token will not continue through the intended flow. As a result, the employee will not be notified of the two successful bookings as they were subsequently canceled. Taking this into account, we need to create a Cancel Event for the Transactional Sub-Process.

 

In the parent Process right-click the Bookings Sub-Process, select the option Attach Event. Choose the Cancel event.

 

Configurind Transactional16

The cancellation flow will send a notification to the employee in order to inform him/her that the booking could not be made.  For this reason, we add a Script task to the flow.

 

Configurind Transactional17

An End Event is used to terminate the Process.

 

8. The diagram still needs to allow for unexpected errors. An Error is raised when something unexpected happens and there is no defined procedure in place to handle it.
We will convert the Flight booking Activity to an automatic task and add an interface to it. If during the execution of the Flight booking automatic task an error arises (connection error, etc.), the Sub-Process will terminate and trigger an exception flow in the main Process.

 

Configurind Transactional18

 

 

To raise the error we need to use an expression once the activity is finished (on exit)  and deviate the normal path towards the error path (shown below). This function will add an error log file in the project folder. The expression should be created on the fourth step of the Process wizard.

 

Configurind Transactional22

 

if(<TransactionProcess.Flight.RandomBoo>!= true)

{

 CHelper.RaiseErrorIntermediateEvent("Error");

}

 

 

The expression needs the following function:

CHelper.RaiseErrorIntermediateEvent("String message")

 

Where String message is a tag to identify the error in the log file.

 

 

9. Finally, we include the exception flow in the parent Process to cater for the potential unexpected error in the Sub-Process.

 

To catch the error, an Error Event  must be attached to the boundaries of the Bookings Sub-Process. Click on the Bookings Sub-Process, select the option Attach Event and then choose Error.

 

 

 

Configurind Transactional19

 

The exception flow will notify the assigned person, in the Administrative Department, of the error.

 

Configurind Transactional20

 

 

 

 

Our Transactional Sub-Process has been successfully configured. You can download a fully functional Transactional Process example from our Process Xchange