Skip to main content
Skip table of contents

Step 3: Handling the Decision

Follow Our Example User Story

Since David's process is an approval process, it includes a decision: The order value can be within the order limit or outside the order limit. He now needs to handle both possible process steps.

The value of the order limit is 1.000. The limit is defined in the ERP system (you are going to define the limit automatically by using the elements from the provided library ERPOrderInterface).

Check the Order Value

Following the process flow, it is now split by a guard expression: Check Order Value. Guard expressions (conditions) of exclusive gateways are implemented to the outgoing relations of the gateway. Click on the relation between the Check order value gateway and service task Check out order. This branch of the process should only be followed if the order value is within a given limit:

tutorial_process_1_check_order_value.png

The corresponding execution diagram is displayed below the BPMN diagram:

order_value_in_limits_execution_diagram.png

Select operation checkOrderValue from class ERPOrder in library ERPOrderInterface. Drag and drop the operation to the action flow on the execution diagram:

add_operation_checkOrderValue.png

Operations that should be able to be used on a guard need to have a Boolean return value. This value should transport the following meaning:

  • true if the process flow should be continued on this branch

  • false if this branch should be omitted

Add persisted variable erpOrder:

add_erp_order_persisted.png

Draw the following object flows:

From

To

persisted variable erpOrder

input pin target

output pin autoCheckout

return value return

checkOrderValue_connected.png

Refer to Exclusive Gateway and Parallel Gateway in the Designer Guide to learn more about gateways in general.

Approve a Valid Order and Check it out

Follow Our Example User Story

David defined in the process model that the order can be approved automatically and checked out if the order value is within the limits.

tutorial_process_check_out.png

Add execution to service task Check out order. Draw the UML execution diagram as depicted on the image below:

  • Add both operations, approveOrder and checkOutOrder from library ERPOrderInterface > ERP > ERPOrder.

  • Add persisted variable erpOrder and connect it to the corresponding target pins.

valid_order_processing.png

Check an Order That Exceeds the Order Limit

Follow Our Example User Story

David defined in the process model that the order should be forwarded to the supervisor, if the permitted order value is exceeded. The supervisor has two options: He can approve the order and arrange that the order is checked out. But he can also reject the order.

tutorial_process_1_check_order_value2.png

Create Another Mapping

Follow Our Example User Story

In order to decide whether to approve or reject the order, the supervisor needs information about the sent order. So David needs to retrieve the data from the order to show it to the supervisor. To be able to do so, David needs to map the data from the order form to the Form_CheckOrder that has been created for the supervisor.

Add a new mapping operation mapOrdertoForm in class Shop of package Mapping in folder Implementation:

add_map_order_to_form.png

Add the following parameters:

  • input parameter webOrder of type ERPOrder

  • output parameter formData of type Form_CheckOrder

map_order_to_form.png

In the related mapping diagram, expand the Input and Output sections:

expand_mapping_map_order_to_form.png

Add an array element to the items array on the input side (item [0] in the picture):

add_array_item_erp.png

Expand the array.

In property openBalance the order value is saved as value of type Float. It contains the result of the input in form field quantity multiplied by the input in form field price from Form_EnterWebOrder. You want to display the order value in Form_CheckOrder, therefore you have to map property openBalance to orderValue in the Output section:

map_order_to_form_expanded.png

Since openBalance and orderValue are not of the same type, you need to convert the value first. In the service panel, open Bridge Base > Base Types > Float. Drag the operation convertToString to the mapping diagram:

convert_to_string.png

Now connect openBalance with the target pin of the operation. Then drag a relation from the return pin to orderValue in the output section:

converting.png

You also want to display the ordered item, therefore draw a second mapping relation:

  • productName: String with orderedItem: String

map_order_to_form_done.png

Add the Mapping Operation to the Process

Follow Our Example User Story

David finished the data mapping. Now he is ready to create the execution model for the step Check order.

Good to Know: What are Execution Models?

You can add one ore more execution models to an execution diagram because the time of execution can be different. For each execution model a corresponding tab is displayed at the bottom of the execution pane. The tab name indicates the time of the execution. Possible tabs are:

  • On Event: The model is executed when the event occurs.

  • On Exit: The model is executed after completion of the task/event.

  • Decision: The model is executed when the process reached the gateway.

  • Get Data: The model is executed when BPMN is waiting in a user task and returns the default values for the form.

For some elements the execution model must be created manually when you want to add execution, for others a default execution diagram is created automatically. Some BPMN elements allow for no execution at all.

If you want to learn more about execution models, refer to the chapter Modeling Execution and Modeling Tasks in the Designer Guide.

Click user task Check order from your process to display the related UML diagram in the execution pane. Delete the execution model On Exit:

delete_on_exit.png

When the execution model has been deleted, the button Add Execution Model appears on the execution pane. Click it and select the model Get Data:

add_get_data.png

The execution model Get Data is now displayed on the canvas, showing three sections:

  • Persisted (Read Only)

  • Local

  • Return (containing the return variable return: Form_CheckOrder)

get_data.png

Select the operation mapOrderToForm you have created in the previous steps (Implementation > Mapping > Shop). Drag and drop the mapping operation to the activity flow in the execution diagram. Operation mapOrderToForm needs an incoming object and provides one outgoing object:

operation_mapOrderToForm.png

You need to provide the form data you want to map as input. Click the arrow icon in the Persisted (Read Only) section and select variable ERPOrder from the list of available persisted variables. Connect the selected variable with pin webOrder of operation mapOrderToForm. Then connect the output pin formData with the return parameter Form_CheckOrder:

execution_get_data_finalized.png

The mapping of order data is done and your service is finished.

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.