Simulating an Order Approval Process
com.atlassian.confluence.content.render.xhtml.migration.exceptions.UnknownMacroMigrationException: The macro 'next_previous_links' is unknown.

Simulating an Order Approval Process

The following example demonstrates creating a business process scenario to simulate an order approval process. The Production Manager invokes an order approval process where it is possible to set the product ID. Additionally, an admin user of the Production Division can set the quantity to order and the unit price of the product. The quantity and the unit price are used to calculate the total cost. If the total cost is above 100,000, the order will have to be approved by an admin user from the Production Division before the order email is dispatched to the Purchasing Division. Alternatively, if the cost is below 100,000, the order email is dispatched to the Purchasing Division without approval. 

Before you begin,

  • Download the product installer from here, and run the installer.

  • Select the relevant WSO2 Integration Studio based on your operating system and download it from here.
    The path to this folder is referred to as <EI_TOOLING> throughout this tutorial.

Let's get started! This tutorial includes the following sections:

Creating the artifacts

Follow the steps below to create the requires artifacts.

  1. Create a new BPMN project named OrderApprovalBPMNFor instructions, see  Creating a BPMN Project .

  2. Create a BPMN Diagram named OrderApproval .bpmn. For instructions, see  Creating the BPMN Diagram .

  3. Click anywhere on the canvas, go to the  Properties  tab, and fill in the following details:
    Id                :  orderApproval
    Name          :  Order Approval Process
    Namespace http://wso2.org/bpmn/orderApproval

  4. To implement the order approval process, drag and drop a StartEvent element, two UserTask elements, a MailTask element and a End Event element on the canvas. 

  5. For each artifact, in the Properties tab, select General and enter the corresponding names as Fill Order FormApprove Order and Order Product as shown below.

  6. According to the business logic in this example, the Start Event should trigger the Fill Order Form User Task. Therefore, in the Connection tab, select Sequence Flow, and connect the Start Event to the Fill Order Form User Task.

  7. Hover your mouse over the Fill Order Form task and click on the Exclusive Gateway icon.

  8. Use the Sequence Flow to connect the other artifacts as shown below.

Configuring the artifacts

After the diagram has been constructed, you must configure the properties of each element to implement the business logic.

Configuring the Start Event

Follow the steps below to configure the Start Event.

  1. Click on the Start Event and set the following values in the General section of the Properties tab.

    • Id: fillOrderDetails

    • Name: Enter Order Details

  2. Click the Start Event and click Form in the Properties tab.

  3. Click the New button, enter the below details to create a productID field and click OK.

    • Id: productID

    • Name: Product Id

    • Type: string

    • Variable: productID

Configuring the User Tasks

Now, you can configure the Fill Order Form User Task, which is a Claimable Task. An administrator of the Production Division can claim and complete the form. 

  1. Click on the Fill Order Form User Task and set fillOrderForm as the ID in the General section of the Properties tab.

  2. Click Main Config in the Properties tab and enter admin as the value of the Candidate Group.

  3. Click Form in the Properties tab, click New each time and add the values in the below table. This creates the form that the employee needs to fill with the productID, quantity and unitPrice fields.  

    Once the above fields are added to the form, the table in your Form should look similar to the following:

  4. Now that you have configured your Fill Order Form User Task, you can identify the two flows: the default flow and conditional flow. Follow the steps below to assign the default flow.

    1.   Click on the Sequence Flow arrow, which connects the Exclusive Gateway to the Mail Task.

    2. Set orderProductFlow as the value of the Id property.

    3. To set orderProductFlow as the default flow, do the following.

      1. Click on the Exclusive Gateway

      2. Click the General tab in the Properties pane and select orderProductFlow in the drop down to assign it.

  5. To assign the Conditional flow, click on the Sequence Flow arrow, which connects the Exclusive Gateway to the Approve Order User Task. In the Main Config section of the Properties tab, enter the following value as the Condition${(quantity*unitPrice) > 100000}


     You have now configured the conditional flow. If the total cost exceeds 100,000, the flow is directed to the Approve Order User Task.

  6. To configure the Approve Order User Task, do the following. 

    1. Click on the Approve Order User Task

    2. In the General section of the Properties tab, enter  approveOrderFlow as the Id. 

    3. In the Main Config section, set the Candidate Group as admin. This enables anyone from the order approval group to claim and complete the task. 

    4. To allow the approver to view the order details, create a form to display the Product ID, Quantity and Unit Price. To do this, navigate to the Form section in the Properties tab and create the fields as shown below.

    Now, you have configured all the BPMN artifacts.

Configuring the Mail Task

To configure the Mail Task, do the following. 

  1. Click on the Order Product  Mail Task and enter orderProduct as the Id in the General section of the Properties tab.

  2. In the Main Config section of the Properties tab, fill the respective fields (i.e., To, From, Subject). 

  3. In the Non-HTML field of the Main Config section, enter Order ${quantity} of ${productID} at the rate of ${unitPrice}. The variable will be used to create the mail body.

  4. Copy the following JAR files into the<EI_HOME>/lib directory and restart the Business Process profile server instance. 

  5. In the <EI_HOME>/wso2/business-process/conf/activiti.xml  fileadd the following properties under the <bean id="processEngineConfiguration" class="org.activiti.engine.impl.cfg.StandaloneProcessEngineConfiguration"> property as shown below, to enable the Gmail configurations.

    • Replace the mailServerHost and mailServerPort property values as follows:

      <property name="mailServerHost" value="smtp.gmail.com"/> <property name="mailServerPort" value="587"/>
    • Add the following properties:

      <property name="mailServerDefaultFrom" value="<ENTER_A_VALID_SMTP_EMAIL_ADDRESS>"/> <property name="mailServerUseTLS" value="true"/> <property name="mailServerUsername" value="<ENTER_A_VALID_SMTP_EMAIL_ADDRESS>"/> <property name="mailServerPassword" value="<ENTER_THE_EMAIL_PASSWORD>"/>
com.atlassian.confluence.content.render.xhtml.migration.exceptions.UnknownMacroMigrationException: The macro 'next_previous_links2' is unknown.